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

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

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
fastapi, python
領域
api, backend

調査の方向性

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.

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

説明

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).
主要言語
Python
スター
1
フォーク
1
平均マージ
4時間 46分
マージ済み PR(30日)
55

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

falbany/ProFiles のほかの issue

falbany/ProFiles の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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