Repository navigation
fix: keep upstream page JSON failures as service errors - #138
Conversation
jerelvelarde
left a comment
There was a problem hiding this comment.
This is a useful bounded API reliability fix: valid page operations no longer blame the caller when Intelligence returns malformed JSON. All five request-validation sites catch JSON parsing failures before invoking a page operation, while PageError/domain and missing-conversation statuses retain their existing mapping. The description accurately states the changed contract and synthetic verification limits. No actionable security finding: upstream error details remain sanitized, malformed caller requests do not write pages or create conversations, and ownership/Space access and revision checks are preserved.
Independent diagnostics through the real PageService with an injected SDK JSON.parse failure reproduce HTTP400 on baseline831f330 and HTTP503 here. They verify no saved page, no provider-detail leak and successful conversation-reservation recovery on retry. All31 focused route/service/provenance checks pass on the exact head and a conflict-free prospective integration with main831f330.
Node24 verification in a clean-environment sandbox with external networking/user credentials inaccessible: formatter, lint, typecheck, full309-test suite and production build pass on the exact head; all gates and315 tests pass on prospective integration. No live Intelligence/provider calls were made. GitHub CI was running at final inspection; merge remains gated on successful CI, unchanged reviewed head and final integration verification against any subsequently merged changes.
fix: keep upstream page JSON failures as service errors
A valid page conversation or save-conversation request currently returns HTTP 400 when the Intelligence operation throws a
SyntaxError, incorrectly reporting a malformed client request. Page routes classify everySyntaxErroras request JSON failure, including errors raised after request validation.Catch JSON body parsing failures at the five request-validation sites, using the same
safeParse(await c.req.json().catch(() => null))pattern as workspace routes. Malformed bodies still return 400 with the route’s validation message and never invoke a page operation. Errors raised by page services now use the existing sanitized 503 response; domain and missing-conversation statuses are preserved.Validation (Node.js 24.21.0, upstream main 625452e):
npm run check-format,npm run lint,npm run typecheck,npm test(48 files, 309 tests), andnpm run buildpass.git diff --checkpasses.The upstream failure tests inject errors at the page-service boundary and use the real Hono API and in-memory SQLite workspace. Live Intelligence calls were not exercised. Vite emits a config-loader warning during tests and a large-chunk warning during build.
Prepared with AI assistance and reviewed by the contributor before submission. This is a newly identified issue; no existing issue is claimed as closed.