Health route 503 hides the real cause of a storage failure, and the store-open failure path is untested

Abierto Apto para principiantes
#276 1 comentario 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
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
nextjs, sqlite, typescript

Línea de trabajo

Empieza en reference-implementations/dacs-directory/app/api/health/route.ts:15 para ver el catch que devuelve el 503 genérico, y luego lee src/catalog/store.ts:45-49, donde se envuelve el fallo de apertura. Ejecuta test/health-route-bad-data-path.test.ts para ver por qué fallan los casos existentes antes de que se abra el store, y después añade un archivo de prueba separado en el que el directorio sea escribible pero directory.sqlite no pueda abrirse. Está terminado cuando el cuerpo del 503 sigue siendo genérico, el log del servidor conserva el error original, los errores del store incluyen error.message y la nueva prueba observa el 503.

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

Descripción

contributors-section minor

Where: reference-implementations/dacs-directory/app/api/health/route.ts:15 (on phase0-completion at the linked commit)

What goes wrong: Three parts of one problem: an operator who gets a 503 from /api/health cannot tell why. (1) The route's catch {} (reference-implementations/dacs-directory/app/api/health/route.ts:15) answers 503 with a generic body and discards the error, so it is impossible to tell whether the directory is unwritable, the database failed to open, or something else broke. (2) When the database cannot be opened, reference-implementations/dacs-directory/src/catalog/store.ts:45-49 always throws "configure DACS_DIRECTORY_DATA to a writable persistent volume", including when better-sqlite3 fails to load its native addon inside the constructor. The original message is kept only as cause, which many log setups do not print. (3) Both tests in reference-implementations/dacs-directory/test/health-route-bad-data-path.test.ts:17 and :23 point the data path at or under a regular file, so mkdirSync throws before the route imports the store and calls loadCatalog(). The 503 for a store that fails to open on a creatable, accessible directory is not tested.

Suggested fix: In route.ts, log the caught error server-side (for example with console.error) and keep the generic 503 body. In store.ts, include error.message in the thrown message and give the writable-volume advice only for path or permission errors. Add a new test file (the store reads DACS_DIRECTORY_DATA once at import, so it needs its own file) where the directory is readable and writable but directory.sqlite cannot be opened (for example a corrupt file) and assert the 503.

Size: Small

This comes from a code review, not from a failing run, so please confirm it before starting. Send the fix as a pull request to phase0-completion. It merges once tests pass and a maintainer has approved it.

Lenguaje dominante
TypeScript
Estrellas
0
Forks
3
Merge medio
20 h 26 min
PR fusionados (30 d)
119

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 DACS-Agent-commerce/Community

Todos los issues de DACS-Agent-commerce/Community

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.