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

Abierto Apto para principiantes
#6,407 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
django, python
Área
backend, testing

Línea de trabajo

Empieza por contentcuration/contentcuration/views/zip.py, especialmente la comprobación de If-Modified-Since, el manejador de BadZipfile y POSSIBLE_ZIPPED_FILE_EXTENSIONS. Lee test_invalid_zip en contentcuration/contentcuration/tests/test_zipcontentview.py y añade cobertura para las solicitudes condicionales de entradas inexistentes y existentes. El trabajo estará terminado cuando las entradas inexistentes y los archivos zip no válidos o no compatibles devuelvan 404 sin un informe de Sentry, mientras que una respuesta 304 para una entrada existente incluya los mismos encabezados CORS que una 200.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
212
Forks
321
Merge medio
1 d 7 h
PR fusionados (30 d)
14

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de learningequality/studio

Todos los issues de learningequality/studio

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.