Skip to content

Handle invalid route returns with ctx.json guidance#161

Open
Squirbie wants to merge 1 commit into
tscircuit:mainfrom
Squirbie:codex/invalid-route-return-guidance-30
Open

Handle invalid route returns with ctx.json guidance#161
Squirbie wants to merge 1 commit into
tscircuit:mainfrom
Squirbie:codex/invalid-route-return-guidance-30

Conversation

@Squirbie
Copy link
Copy Markdown

Summary

  • add an early route-response guard for unsupported handler return values before response serialization reads status or uses the in operator
  • keep the existing raw-object guidance message and add AVA coverage for undefined, null, primitive, symbol, and function returns

/claim #30

Validation

  • npx ava tests/errors/do-not-allow-raw-json.test.ts
  • npx prettier --check src/create-with-winter-spec.ts tests/errors/do-not-allow-raw-json.test.ts
  • git diff --check

Notes

  • npm ci is currently blocked because package-lock.json is not in sync with package.json for esbuild optional packages.
  • npm test -- tests/errors/do-not-allow-raw-json.test.ts reaches the pretest build and is blocked by existing TypeScript errors in src/cli/commands/codegen/openapi.ts and src/cli2/commands/codegen/openapi.ts about operation.responses possibly being undefined. The focused AVA regression test above passes.

@Squirbie
Copy link
Copy Markdown
Author

Follow-up after checking the open PR queue: this overlaps materially with earlier clean invalid-route-return PRs, especially #156 and #157, and partially with narrower cases like #158/#152/#154. I missed those before opening this PR. Please treat this PR as an alternate/reference implementation rather than a first claim; I am happy to close it if maintainers prefer to keep the earlier candidates active.

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