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

未關閉 適合新手
#2,505 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@sanchit955 已經在處理了。

開始於 2026年11月17日。

  • #2506 來自 @sanchit955 —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
85/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
django, postgresql, python
領域
backend, databases

研究方向

從 vulnerabilities/models.py 中的 PipelineSchedule.pipeline_class 開始,接著追蹤它在 PipelineRunListView、PipelineRunDetailView 以及 PipelineRun.pipeline_url 中的使用。執行 vulnerabilities/tests/test_view.py 中新增的 PipelineRunViewsUnregisteredPipelineTestCase;對於未註冊的 pipeline,當兩個執行頁面都回傳 200,並將其 id 顯示為頁面名稱時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
Python
星號
719
分支
359
平均合併
11 小時 59 分鐘
30 天內合併 PR
2

環境準備

  • 提供 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 沒有貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

aboutcode-org/vulnerablecode 的其他 Issue

查看 aboutcode-org/vulnerablecode 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。