server: config save/content endpoints convert OSError and UnicodeDecodeError into raw 500s; inconsistent missing-file semantics (400/404/200)

Abierto
#137 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
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
fastapi, python
Área
api, backend

Línea de trabajo

Read the config endpoints in routes/config.py at the cited locations for /load, /reload, /content, /save, and /save-as, then check the ValidationIssue[] contract in client.ts:36-54. Trace the read, decode, and write failures alongside the existing status responses. Done means the endpoints handle these failures consistently and the validation response shape follows the documented contract; the issue leaves the exact error status choice open.

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

Descripción

bug

Problem

Error handling across the config endpoints is inconsistent and leaks tracebacks:

  • save_config_endpoint: on_disk_hash = content_hash(config_path.read_text(encoding="utf-8")) (routes/config.py:458) — raises UnicodeDecodeError/OSError → unhandled 500 before the staleness guard can answer 409. write_text_atomic(config_path, payload.content) (config.py:471) raises OSError on read-only target/full disk → raw 500 traceback instead of an actionable 4xx; same in save_as_config_endpoint (config.py:540).
  • GET /content's config_path.read_text(encoding="utf-8") (config.py:405) 500s on non-UTF-8 files.
  • Missing-file semantics for the same situation differ per endpoint: /load → 400 (config.py:171), /content → 404 (config.py:400-403), /reload → 200 {"reloaded": false} (config.py:337-339).
  • Validation-failure shape is heterogeneous: /save and /save-as put the issue list in detail (HTTPException(400, detail=issues)) while every other 4xx uses a string, and /validate returns the same data as a 200 body — three shapes for one concern (the client compensates in apiError(), client.ts:36-54).

Suggested fix

  1. Wrap the write/read calls in try/except OSError as e: raise HTTPException(422 or 500-with-detail, f"Cannot write configuration file: {e}").
  2. Pick one missing-file status (404) for all three endpoints.
  3. Keep the list-detail 400s but document them in one place (they are already the ValidationIssue[] contract in client.ts).
Lenguaje dominante
Python
Estrellas
1
Forks
1
Merge medio
4 h 46 min
PR fusionados (30 d)
55

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

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 falbany/ProFiles

Todos los issues de falbany/ProFiles

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.