Affected-by-advisories v2 page returns 500 for a purl with no matching package

Open Beginner friendly
#2,501 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@sanchit955 is already working on this.

Since Nov 16, 2026.

  • #2502 by @sanchit955 — open

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
django, python
Domain
backend, security

Research direction

Start in vulnerabilities/views.py at AffectedByAdvisoriesListView.get_context_data and trace its call to get_fixed_package_details(). Check how the template handles an empty mapping through the get_item filter, then run the relevant view tests. Done means a purl with no matching package renders successfully with zero results instead of returning HTTP 500.

Written by the indexing model from the issue text.

Description

Visiting the affected-by-advisories v2 page for a package that is not in the database returns a 500 instead of an empty result list.

Steps to reproduce

  1. Open /affected-by-advisories/v2/pkg:pypi/[email protected] (after the Altcha challenge).
  2. The page returns HTTP 500.

What happens

AffectedByAdvisoriesListView.get_context_data looks the purl up with PackageV2.objects.for_purl(purl).first(), which returns None when there is no matching package, and passes it straight to get_fixed_package_details(). That helper dereferences package.affected_in_impacts, so it raises:

AttributeError: 'NoneType' object has no attribute 'affected_in_impacts'

(vulnerabilities/views.py:441)

Expected behaviour

The page should render with zero results, the same as any other purl with no affecting advisories. A mistyped or not-yet-imported package link should not 500.

Notes

  • The same helper is also used by PackageV2Details, but there self.object is never None (the detail view 404s first), so only this list view is affected.
  • The fix is a None guard in get_fixed_package_details() returning an empty mapping, which the template already handles through the get_item filter.
Dominant language
Python
Stars
719
Forks
359
Avg merge
11h 59m
Merged PRs (30d)
2

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aboutcode-org/vulnerablecode

All issues in aboutcode-org/vulnerablecode

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.