Skip to content

Conversation

@mr-raj12
Copy link

@mr-raj12 mr-raj12 commented Jan 2, 2026

Summary

  • Fix get_advisory_url() in utils.py to accept both Path objects and strings
  • Converts string inputs to Path objects before calling .relative_to()
  • Resolves the AttributeError: 'str' object has no attribute 'relative_to' error

Issue

Fixes :

Changes

  • Added from pathlib import Path import
  • Added type checking with isinstance() to convert strings to Path objects

Testing

  • All 96 v2 importer tests pass
  • All 7 utils tests pass
  • Manually tested with both Path and string inputs

Signed-off-by: Mrityunjay Raj [email protected]

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 <[email protected]>
@mr-raj12 mr-raj12 force-pushed the fix-istio-importer-path branch from f68153c to 1608222 Compare January 2, 2026 16:53
@ziadhany
Copy link
Collaborator

ziadhany commented Jan 9, 2026

@mr-raj12, could you please add a simple test for the get_advisory_url function?

- 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 <[email protected]>
@mr-raj12
Copy link
Author

@ziadhany Test added for get_advisory_url() function as requested.

The test covers:

  • String inputs (the bug fix scenario that caused the original issue)
  • Path object inputs (original working case)
  • Mixed Path/string inputs

All tests pass locally. The PR is ready for review.

@mr-raj12
Copy link
Author

@ziadhany Test has been added as requested. All test suites pass successfully.

Note: The documentation build is failing due to a broken link in contributing.rst:75 that exists in the main branch - this is unrelated to my changes. I only added a test file and didn't modify any documentation.

Could you please advise if I should:

  1. Wait for this to be fixed in main and then rebase
  2. Fix the broken link in this PR
  3. Proceed as-is since all tests pass

Let me know if you'd like me to fix the documentation link as part of this PR.

@ziadhany
Copy link
Collaborator

ziadhany commented Jan 13, 2026

@mr-raj12 Ignore the CI docs for now, just run the Istio importer locally again and print the logs.

@ziadhany ziadhany self-requested a review January 13, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants