Skip to content

fix: keep upstream page JSON failures as service errors - #138

Merged
jerelvelarde merged 1 commit into
CopilotKit:mainfrom
xiajiahang:fix/page-upstream-json-status
Oct 14, 2026
Merged

jerelvelarde merged 1 commit into
CopilotKit:mainfrom
xiajiahang:fix/page-upstream-json-status

Conversation

@xiajiahang

Copy link
Copy Markdown
Contributor

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 every SyntaxError as 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):

  • Confirmed both new upstream parsing regression cases fail on the original implementation (400 instead of 503), then pass with the fix.
  • Added malformed-body coverage for all five page write endpoints.
  • npm run check-format, npm run lint, npm run typecheck, npm test (48 files, 309 tests), and npm run build pass.
  • git diff --check passes.

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.

@jerelvelarde jerelvelarde left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jerelvelarde
jerelvelarde merged commit 535b494 into CopilotKit:main Oct 14, 2026
1 check passed
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.

2 participants