8000 fix: replace exit with proper error handling in LicenseMainGetter.php and spdx.php by IshaanAggrawal · Pull Request #3067 · fossology/fossology · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: replace exit with proper error handling in LicenseMainGetter.php and spdx.php #3067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

IshaanAggrawal
Copy link
@IshaanAggrawal IshaanAggrawal commented Jun 5, 2025

Fixes #3061

… and spdx.php

Description

Null-check:
Checks if $allLicenseCols is null. This means the code tried to look up a license (using $originLicenseId), but there was no matching record in the database.

Logging:
If the license is missing, it writes an error message to the PHP error log, including the license ID that was not found.

Continue:
The continue; statement skips the rest of the current loop iteration and moves on to the next license in the list.
This way, the missing license doesn’t stop the whole process—other licenses will still be processed.

Changes Made

if ($allLicenseCols === null) {
  error_log("Error: License ID " . $originLicenseId . " not found in the database.");
  continue; // Skip this license and continue with others
}

@IshaanAggrawal IshaanAggrawal changed the title Fix: Fixes #3061 replace exit with continue LicenseMainGetter.php… Fix: replace exit with continue LicenseMainGetter.php… Jun 5, 2025
@IshaanAggrawal
Copy link
Author

please review my changes

@IshaanAggrawal IshaanAggrawal changed the title Fix: replace exit with continue LicenseMainGetter.php… fix: replace exit with continue in LicenseMainGetter.php Jun 9, 2025
@IshaanAggrawal IshaanAggrawal changed the title fix: replace exit with continue in LicenseMainGetter.php fix: replace exit with proper error handling in LicenseMainGetter.php and spdx.php Jun 9, 2025
@IshaanAggrawal
Copy link
Author

please check it now There was a typo by my end I had used Fix insted of fix

@shaheemazmalmmd
Copy link
Member

@IshaanAggrawal : please check the fsiling testcases and squash your commits to one

@Aditya30ag
Copy link

I have created a new PR where i have implement this properly so you can see an review it

@IshaanAggrawal IshaanAggrawal force-pushed the fix-exit-statements branch 4 times, most recently from 91ccf83 to a0ab8b8 Compare June 17, 2025 04:13
@IshaanAggrawal
Copy link
Author
IshaanAggrawal commented Jun 17, 2025

@shaheemazmalmmd Sir I have sent you linkedin request by name Ishaan Aggrawal so that there could be better discussion or do you have any discord etc for better communication instead of github

@shaheemazmalmmd
Copy link
Member

@shaheemazmalmmd Sir I have sent you linkedin request by name Ishaan Aggrawal so that there could be better discussion or do you have any discord etc for better communication instead of github

Sure. we also use slack you can join using https://join.slack.com/t/fossology/shared_invite/enQtNzI0OTEzMTk0MjYzLTYyZWQxNDc0N2JiZGU2YmI3YmI1NjE4NDVjOGYxMTVjNGY3Y2MzZmM1OGZmMWI5NTRjMzJlNjExZGU2N2I5NGY

… and spdx.php

Signed-off-by: Ishaan Aggrawal <ishaanaggrawal101@gmail.com>
@IshaanAggrawal IshaanAggrawal force-pushed the fix-exit-statements branch from 8000 a0ab8b8 to 1e49865 Compare June 20, 2025 16:56
@shaheemazmalmmd shaheemazmalmmd requested a review from Copilot June 25, 2025 07:21
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves error handling by replacing abrupt exit calls with continue in two license-processing routines, ensuring that missing licenses are logged and skipped without halting the entire process.

  • Changed exit to continue when a license lookup returns null
  • Adjusted the log level in spdx.php from “Error” to “Warning”
  • Added consistent skip logic for missing licenses in both routines

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/spdx/agent/spdx.php Swapped exit for continue and changed log prefix to “Warning”
src/lib/php/Report/LicenseMainGetter.php Replaced exit with continue to skip missing license IDs
Comments suppressed due to low confidence (3)

src/spdx/agent/spdx.php:386

  • Add a unit or integration test to cover the case where getLicenseById returns null, verifying that the warning is logged and processing continues without error.
            "spdx: Warning: main license ID {$reportedLicenseId} not found; skipping."

src/lib/php/Report/LicenseMainGetter.php:45

  • [nitpick] The log in this file uses the prefix Error: while spdx.php uses spdx: Warning:. Consider standardizing your log format and severity prefixes across both modules for consistency.
        continue; // Skip this license and continue with others

src/spdx/agent/spdx.php:388

  • Ensure that this continue is inside the loop that iterates reported licenses; if it’s not, PHP will error. If this block isn’t within a loop, consider using return or restructuring the control flow.
        continue; // Skip this license and continue with the next one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Process should not exit
3 participants
0