Fix get_advisory_url to handle string file paths#2102
Fix get_advisory_url to handle string file paths#2102mr-raj12 wants to merge 2 commits intoaboutcode-org:mainfrom
Conversation
The function now accepts both Path objects and strings for the `file` and `base_path` parameters, converting strings to Path objects before calling relative_to(). This fixes the AttributeError that occurred when importers passed string paths instead of Path objects. Fixes: aboutcode-org#2016 Signed-off-by: Mrityunjay Raj <mr.raj.earth@gmail.com>
f68153c to
1608222
Compare
|
@mr-raj12, could you please add a simple test for the |
- Test string inputs (the bug fix scenario) - Test Path object inputs (original working case) - Test mixed Path/string inputs Addresses reviewer feedback Signed-off-by: Mrityunjay Raj <mr.raj.earth@gmail.com>
|
@ziadhany Test added for The test covers:
All tests pass locally. The PR is ready for review. |
|
@ziadhany Test has been added as requested. All test suites pass successfully. Note: The documentation build is failing due to a broken link in Could you please advise if I should:
Let me know if you'd like me to fix the documentation link as part of this PR. |
|
@mr-raj12 Ignore the CI docs for now, just run the Istio importer locally again and print the logs. |
|
@ziadhany ran the Istio importer locally as requested. The fix works correctly - no more The importer successfully processed all 50 Istio advisories without errors. |
|
@mr-raj12 we appreciate your willingness to contribute, but stop using AI, as this is not a productive use of our review time. We can also use Claude Code ourselves, and we would not need you as an intermediary. Instead, you are likely a smart person, and we will enjoy reviewing your hand-cratfed code, without AI-vibing being used. As a small test for you: how can you make your code change in utils.py from 4 lines to 1 line? (Please do not use AI for this) |
Summary
get_advisory_url()inutils.pyto accept bothPathobjects and stringsPathobjects before calling.relative_to()AttributeError: 'str' object has no attribute 'relative_to'errorIssue
Fixes :
Changes
from pathlib import Pathimportisinstance()to convert strings to Path objectsTesting
Signed-off-by: Mrityunjay Raj mr.raj.earth@gmail.com