-
Notifications
You must be signed in to change notification settings - Fork 471
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
base: master
Are you sure you want to change the base?
fix: replace exit with proper error handling in LicenseMainGetter.php and spdx.php #3067
Conversation
please review my changes |
317460f
to
2ec546d
Compare
please check it now There was a typo by my end I had used Fix insted of fix |
@IshaanAggrawal : please check the fsiling testcases and squash your commits to one |
faa33f1
to
4e2ab86
Compare
I have created a new PR where i have implement this properly so you can see an review it |
91ccf83
to
a0ab8b8
Compare
@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>
a0ab8b8
to
1e49865
Compare
There was a problem hiding this 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
tocontinue
when a license lookup returnsnull
- 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
returnsnull
, 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:
whilespdx.php
usesspdx: 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 usingreturn
or restructuring the control flow.
continue; // Skip this license and continue with the next one
Fixes #3061
… and spdx.php
Description
Null-check:
Checks if
$allLicenseCols
isnull
. 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