zipcontent returns 304 before checking the entry exists, and 500 for non-zip files

オープン 初心者向け
#6,407 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
django, python
領域
backend, testing

調査の方向性

まず contentcuration/contentcuration/views/zip.py を確認し、特に If-Modified-Since のチェック、BadZipfile ハンドラー、POSSIBLE_ZIPPED_FILE_EXTENSIONS に注目してください。contentcuration/contentcuration/tests/test_zipcontentview.py の test_invalid_zip を読み、存在しないエントリと既存のエントリに対する条件付きリクエストのテストを追加してください。存在しないエントリと無効または未対応の zip ファイルが Sentry レポートなしで 404 を返し、既存のエントリに対する 304 が 200 と同じ CORS ヘッダーを含めば完了です。

索引モデルが issue の本文から書いたものです。

説明

DEV: backend

Overview

ZipContentView answers any request carrying an If-Modified-Since header with 304 before it checks the entry inside the zip exists. For a stored file that isn't a zip, it returns a deliberate 500 and reports it to Sentry on every request. Both are reachable anonymously.

Complexity: Low
Target branch: hotfixes

Context

All behaviour below was reproduced:

  • The If-Modified-Since check runs before the lookup. If-Modified-Since: garbage on a nonexistent entry returns 304 instead of 404, and the 304 has none of the CORS headers the 200 carries.
  • The BadZipfile handler returns HttpResponseServerError and calls capture_message. /zipcontent/<checksum>.pdf/index.html reaches it. POSSIBLE_ZIPPED_FILE_EXTENSIONS is defined but never checked.
  • test_invalid_zip in contentcuration/contentcuration/tests/test_zipcontentview.py asserts the 500.
  • Related: #906, #844.
The Change
  • If-Modified-Since should only produce a 304 for an entry that exists, and the 304 should carry the same CORS headers as the 200.
  • A request for a stored file whose extension isn't in POSSIBLE_ZIPPED_FILE_EXTENSIONS, or that isn't a valid zip, should return 404 without a Sentry report.
Acceptance Criteria
General
  • A request with any If-Modified-Since for a nonexistent entry returns 404.
  • A request with If-Modified-Since for an existing entry returns 304 with the same CORS headers as the 200.
  • /zipcontent/<checksum>.pdf/index.html returns 404 and sends nothing to Sentry.
Testing
  • test_invalid_zip asserts 404, and new tests cover the two If-Modified-Since cases.

AI usage

I scoped the audit. Claude Code found and reproduced these failures and drafted this issue.

主要言語
Python
スター
212
フォーク
321
平均マージ
1日 7時間
マージ済み PR(30日)
14

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

learningequality/studio のほかの issue

learningequality/studio の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。