vulnerablecode icon indicating copy to clipboard operation
vulnerablecode copied to clipboard

Pipeline run pages return 500 for a schedule whose pipeline is not registered

Open sanchit955 opened this issue 2 weeks ago • 1 comments

Problem

PipelineSchedule rows persist in the database. When a pipeline is removed or renamed (for example the open "Remove v1 code" work), every stale schedule's run pages crash:

  • GET /pipelines/<pipeline_id>/runs/ → 500
  • GET /pipelines/<pipeline_id>/run/<uuid>/ → 500

Evidence

PipelineSchedule.pipeline_class (vulnerabilities/models.py) does a bare dict lookup, pipeline_registry[self.pipeline_id], which raises KeyError for an id that is no longer registered. Both PipelineRunListView.get_context_data and PipelineRunDetailView.get_context_data dereference it (pipeline_class.__name__), and the run detail template also reaches it through PipelineRun.pipeline_url when the run has a commit recorded.

Reproduced locally on PostgreSQL 16 with a schedule and a run using pipeline_id="hunt_probe_no_such_pipeline": both pages 500 with KeyError: 'hunt_probe_no_such_pipeline'. The dashboard list page is not affected — its template never calls pipeline_class.

Fix

  • pipeline_class returns None for an unregistered id (.get() instead of []); description already guards on a falsy class.
  • Both views fall back to the raw pipeline_id as the page name when the class is unknown.
  • pipeline_url returns None when the class is unknown, so the detail template's commit link degrades cleanly.

Tests

New PipelineRunViewsUnregisteredPipelineTestCase in vulnerabilities/tests/test_view.py: both pages return 200 with the pipeline id as the name for an unregistered pipeline. Both tests fail on unmodified main and pass with the fix. Full test_view.py: 14 passed (1 pre-existing flaky timing failure in test_aggregate_fixed_and_affected_packages, fails on main too); pipeline model tests 10 passed.

sanchit955 avatar Nov 17 '26 05:11 sanchit955

@sanchit955 this issue is AI generated slop. Did you ever bother to go through the code? Because if you did you would not have entered this issue. An unregistered/removed pipeline and its run are deleted during scheduler initialization and accessing removed pipeline would give 404 error, which is the desired behaviour.

See an example of removed pipeline: https://public.vulnerablecode.io/pipelines/vulnerabilities.importers.curl.CurlImporter/runs/, this will give 404 error and not 500, as suggested in your issue.

keshav-space avatar Nov 27 '26 10:11 keshav-space