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

オープン 初心者向け
#276 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
nextjs, sqlite, typescript

調査の方向性

reference-implementations/dacs-directory/app/api/health/route.ts:15 から始めて、汎用的な 503 を返す catch を確認してください。次に src/catalog/store.ts:45-49 を読み、オープン失敗がどこでラップされているかを確認します。test/health-route-bad-data-path.test.ts を実行して、ストアを開く前に既存のケースが失敗する理由を確認し、そのうえで、ディレクトリは書き込み可能だが directory.sqlite を開けない状況を再現する別のテストファイルを追加してください。完了の条件は、503 のレスポンス本文が汎用のままであること、サーバーログに元のエラーが残ること、ストアのエラーに error.message が含まれること、そして新しいテストが 503 を検証していることです。

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

説明

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.

主要言語
TypeScript
スター
0
フォーク
3
平均マージ
20時間 26分
マージ済み PR(30日)
119

環境構築

はじめの一歩

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

DACS-Agent-commerce/Community のほかの issue

DACS-Agent-commerce/Community の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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