Public v2 endpoints answer 304 before the view runs and cache error responses

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

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

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

評価

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

調査の方向性

Read contentcuration/kolibri_public/views.py around metadata_cache and get_last_modified, then inspect the tests for the contentnode and contentnode_tree endpoints. Add coverage for conditional requests, error response cache headers, and unchanged caching on successful responses; done means all listed acceptance criteria pass.

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

説明

DEV: backend

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

metadata_cache wraps every public v2 endpoint in Django's last_modified, keyed on the newest ChannelMetadata.last_updated across all channels. Django answers a request whose If-Modified-Since is later than that with 304 before the view runs, so a request for a missing node, or with invalid parameters, gets 304 instead of 404 or 400. The decorator also marks error responses public and cacheable for 5 minutes, so a CDN serves them to everyone.

Complexity: Low
Target branch: hotfixes

Context
  • metadata_cache and get_last_modified apply last_modified, patch_response_headers and patch_cache_control(public=True) to every response.
  • Reproduced: GET /api/public/v2/contentnode/<nonexistent id>/ with an If-Modified-Since later than the newest channel update returns 304. A 404 or 400 response carries Cache-Control: max-age=300, public, stale-while-revalidate=100.
The Change
  • A conditional request should get 304 only when the view would otherwise return 200.
  • Error responses should not be marked public or cacheable.
Acceptance Criteria
General
  • A request for a missing node or with invalid parameters returns its 404 or 400 whatever its If-Modified-Since.
  • 4xx and 5xx responses from public v2 endpoints carry no public Cache-Control or max-age.
  • 200 responses keep their current caching headers, and conditional requests for them still get 304.
Testing
  • Tests cover each criterion on the contentnode and contentnode_tree endpoints.

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 を短くまとめたダイジェスト。