Skip to content

fix(relay): 本文が JSON の null のとき relay/jpyc と csv-pass/relay が 500 になるのを 400 にする (B-R6f・掟 15) - #624

Merged
cipherwebllc merged 3 commits into
mainfrom
fix/r6-b6f-null-body
Sep 24, 2026
Merged

cipherwebllc merged 3 commits into
mainfrom
fix/r6-b6f-null-body

Conversation

@cipherwebllc

@cipherwebllc cipherwebllc commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

概要

第 6 回レビュー Phase 6 の R6b (#623) の characterization で見つかった既存の問題です (B-R6f)。
JSON.parse (または req.json()) の結果が JSON の null のとき、そのまま欄を読んで TypeError になり、500 (または 503) と Sentry event を出す route が 6 つありました。

route 修正前 修正後
POST /api/relay/jpyc (money-path) 500 + Sentry 400 invalid_payload
POST /api/csv-pass/relay (money-path) 500 + Sentry 400 invalid_payload
POST /api/auth/siwe/verify (未ログインで到達可) 503 verify_failed + Sentry 400 invalid_json
POST /api/billing/settle (money-path) 500 400 invalid_json (null だけ)
POST /api/freee/mapping・/api/freee/sync (SIWE の後ろ・機能は保留中) 500 400 invalid_json

変更 (掟 12 の「追加のみ」)

parse の直後に検査を 1 つ足しただけです。error code は各 route が既に持つもの (relay は欄不足と同じ invalid_payload、他は invalid_json) を使い、既存の制御フロー・応答・エラー処理は変えていません。money-path の billing/settle は null だけを対象にし、文字列や数値の本文は従来どおり invalid_chain のままです。

⚠️ 掟 15: relay と billing の money-path の route に触れます。merge 前に user の明示レビューをお願いします。 検査は状態変化・KV 書き込み・冪等性の claim・予算・nonce の消費・session 作成の前に置いており、資金の危険はありません。

検証

  • 追加したテスト 6 件 (relay 2・siwe 1・billing 1・freee 2: null 本文 → 400) は、それぞれのガードを外すと落ちます。
  • 関連 7 file のテストは全件通過。typecheck 0 / eslint 0。
  • 別セッションの Opus 5.5 のレビュー: relay 2 route の時点で approve → 「同じ型の route が 4 つある」との指摘で拡張 → 追加分も approve (should-fix 2 件 = billing を null だけに絞る・freee のテスト追加、どちらも反映済み)。

🤖 Generated with Claude Code

https://claude.ai/code/session_01HeizmagJBgL5peL5mQpxkc

@vercel

vercel Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
openpay Ignored Ignored Preview Sep 24, 2026 5:07pm UTC

Request Review

cipherwebllc and others added 3 commits September 25, 2026 02:06
…のを 400 にする (B-R6f・掟 15)

第 6 回レビュー R6b の characterization で判明。JSON.parse が null を返すと raw.chainId で
TypeError → 500 + Sentry event になっていた。JSON.parse の直後に object 以外を
400 invalid_payload で返す検査を足す (追加のみ・register/claim と relay/status と同じ線)。

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HeizmagJBgL5peL5mQpxkc
… 本文を 400 で返す (B-R6f)

レビューで同じ型 (parse 結果が null のまま欄を読む → TypeError) の route が 4 つ見つかった。
siwe/verify は未ログインで到達でき 503 verify_failed + Sentry になっていた。
いずれも既存の invalid_json と同じ 400 を、欄を読む前に返す (追加のみ)。
freee の 2 route は SIWE の後ろで inert のため、テストは siwe/billing の 2 件を追加。

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HeizmagJBgL5peL5mQpxkc
…ー反映)

billing/settle は money-path なので、文字列/数値の本文の error code (invalid_chain) を変えず
JSON の null だけを 400 invalid_json にする (pro/subscribe と同じ線)。freee mapping/sync は
既存の integration test の helper で null 本文 → 400 を固定した。

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HeizmagJBgL5peL5mQpxkc
@cipherwebllc
cipherwebllc merged commit ddacf18 into main Sep 24, 2026
8 checks passed
@cipherwebllc
cipherwebllc deleted the fix/r6-b6f-null-body branch September 24, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant