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 mr.raj.earth@gmail.com

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>
@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 <mr.raj.earth@gmail.com>
@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
@mr-raj12
Copy link
Author

mr-raj12 commented Jan 13, 2026

@ziadhany ran the Istio importer locally as requested. The fix works correctly - no more AttributeError. Here are the logs:

Importing data using istio_importer_v2
INFO 2026-01-13 22:55:45.795668 UTC Pipeline [IstioImporterPipeline] starting
INFO 2026-01-13 22:55:45.795840 UTC Step [clone] starting
INFO 2026-01-13 22:55:45.795904 UTC Cloning `git+https://github.com/istio/istio.io`
INFO 2026-01-13 22:59:23.746128 UTC Step [clone] completed in 218 seconds (3.6 minutes)
INFO 2026-01-13 22:59:23.746558 UTC Step [collect_and_store_advisories] starting
INFO 2026-01-13 22:59:23.749206 UTC Collecting 50 advisories
INFO 2026-01-13 22:59:23.922442 UTC Progress: 10% (5/50) ETA: 2 seconds
INFO 2026-01-13 22:59:24.054695 UTC Progress: 20% (10/50) ETA: 1 seconds
INFO 2026-01-13 22:59:24.183932 UTC Progress: 30% (15/50) ETA: 1 seconds
INFO 2026-01-13 22:59:24.330724 UTC Progress: 40% (20/50) ETA: 1 seconds
INFO 2026-01-13 22:59:24.461186 UTC Progress: 50% (25/50) ETA: 1 seconds
INFO 2026-01-13 22:59:24.573701 UTC Progress: 60% (30/50) ETA: 1 seconds
INFO 2026-01-13 22:59:24.698512 UTC Progress: 70% (35/50)
INFO 2026-01-13 22:59:24.826147 UTC Progress: 80% (40/50)
INFO 2026-01-13 22:59:24.974783 UTC Progress: 90% (45/50)
INFO 2026-01-13 22:59:25.083145 UTC Progress: 100% (50/50)
INFO 2026-01-13 22:59:25.118561 UTC Successfully collected 50 advisories
INFO 2026-01-13 22:59:25.118795 UTC Step [collect_and_store_advisories] completed in 1 seconds
INFO 2026-01-13 22:59:25.118893 UTC Step [clean_downloads] starting
INFO 2026-01-13 22:59:25.118955 UTC Removing cloned repository
INFO 2026-01-13 22:59:32.576756 UTC Step [clean_downloads] completed in 7 seconds
INFO 2026-01-13 22:59:32.576930 UTC Pipeline completed in 227 seconds (3.8 minutes)

The importer successfully processed all 50 Istio advisories without errors.

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