Repository navigation
fix(views): return empty fixed-package details for unknown purls - #2502
Open
sanchit955 wants to merge 1 commit into
Open
sanchit955 wants to merge 1 commit into
sanchit955 wants to merge 1 commit into
Conversation
The affected-by-advisories v2 page crashed with AttributeError when the requested purl has no matching package in the database: for_purl().first() returns None and get_fixed_package_details() dereferenced it. Return an empty mapping for a missing package so the page renders zero results instead of a 500. Add a regression test covering an unknown purl. Signed-off-by: Sanchit <[email protected]>
sanchit955
force-pushed
the
fix/affected-by-unknown-purl-500
branch
from
November 16, 2026 09:06
53570d4 to
dc477a9
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2501
The affected-by-advisories v2 page 500s for any purl with no matching package in the database:
for_purl(purl).first()returnsNoneandget_fixed_package_details()dereferences it (AttributeError: 'NoneType' object has no attribute 'affected_in_impacts').This makes
get_fixed_package_details()return an empty mapping when the package isNone, so the page renders zero results instead of a 500. The template already reads the value through theget_itemfilter, so an empty mapping renders cleanly.PackageV2Detailsis unaffected — thereself.objectis neverNone.Tests
AffectedByAdvisoriesListViewTestCaseinvulnerabilities/tests/test_view.py: an unknown purl returns 200, an emptyfixed_package_detailsand an empty page. The test fails on unmodified main and passes with the fix.vulnerabilities/tests/test_view.pyon PostgreSQL 16: 13 passed; the one failure is the pre-existing flaky timing assertion intest_aggregate_fixed_and_affected_packages(it asserts a request completes in under 0.06 s; it fails on unmodified main too).black --checkclean on both changed files.