Skip to content

Handle undefined route returns with helpful guidance#158

Open
CharlieLZ wants to merge 1 commit into
tscircuit:mainfrom
CharlieLZ:codex/30-undefined-return-guidance
Open

Handle undefined route returns with helpful guidance#158
CharlieLZ wants to merge 1 commit into
tscircuit:mainfrom
CharlieLZ:codex/30-undefined-return-guidance

Conversation

@CharlieLZ
Copy link
Copy Markdown

Summary

  • add a regression test for route handlers that accidentally return undefined
  • guard missing/primitive route responses before response serialization reads .status
  • surface an actionable message telling users to use ctx.json({...}) or return a Response

Why

Current main still allows undefined route returns to reach serializeResponse, where .status is read before the existing raw-object guidance middleware can run. That produces a low-level serialization failure instead of the issue #30 guidance.

This is narrower than the raw-object case and keeps existing return { ... } behavior intact.

Verification

  • npm test -- tests/errors/do-not-allow-raw-json.test.ts -> 2 passed
  • npm run lint -> passed
  • npm run typecheck -> passed
  • npm test -> 186 passed, 18 skipped

/claim #30

@CharlieLZ
Copy link
Copy Markdown
Author

Ready for review. This PR adds explicit guidance for route handlers that resolve to undefined, with focused coverage for the regression case.\n\nVerification run locally:\n- npm test -- tests/errors/do-not-allow-raw-json.test.ts\n- npm run lint\n- npm run typecheck\n- npm test\n\nHappy to adjust wording or error shape if you prefer a different developer-facing message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant