Skip to content

Guard invalid route return values with ctx.json guidance#156

Open
isiliconx wants to merge 2 commits into
tscircuit:mainfrom
isiliconx:guard-invalid-route-return-values
Open

Guard invalid route return values with ctx.json guidance#156
isiliconx wants to merge 2 commits into
tscircuit:mainfrom
isiliconx:guard-invalid-route-return-values

Conversation

@isiliconx
Copy link
Copy Markdown

@isiliconx isiliconx commented May 23, 2026

Summary

  • Add a shared guard for unsupported route return values before response serialization reads .status or uses the in operator
  • Reuse the existing ctx.json({...}) guidance for raw objects and invalid primitive/function/null/undefined returns
  • Add regression coverage for undefined, null, string, number, boolean, bigint, symbol, and function returns

Testing

  • npm test -- tests/errors/do-not-allow-raw-json.test.ts
  • npm run typecheck
  • npx prettier --check src/create-with-winter-spec.ts src/middleware/with-response-object-check.ts src/middleware/route-return-value-error.ts tests/errors/do-not-allow-raw-json.test.ts
  • git diff --check

Note: on Windows, npm run build/pretest can prompt if dist already exists because the repo uses del dist; I removed only this repo's dist directory before rerunning checks.

/claim #30

AI-assisted; I reviewed the patch and verification results.

Copy link
Copy Markdown
Author

Quick status check on this one: the invalid route return guard is still open/mergeable, the Bun test workflow is green, and the Algora claim is still pending.

Happy to adjust the approach if you want this handled differently before merge.

Copy link
Copy Markdown
Author

Follow-up status: this PR is still open/mergeable, and the current head's Run Tests with Bun workflow is passing. The Algora claim page is still showing Total paid $0 / Status Pending.

Happy to make any final adjustments needed for merge.

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