Skip to content

fix: throw clear error for invalid route return values - #165

Open
MikeGarciaAGM wants to merge 1 commit into
tscircuit:mainfrom
MikeGarciaAGM:fix/route-response-error-30
Open

fix: throw clear error for invalid route return values#165
MikeGarciaAGM wants to merge 1 commit into
tscircuit:mainfrom
MikeGarciaAGM:fix/route-response-error-30

Conversation

@MikeGarciaAGM

@MikeGarciaAGM MikeGarciaAGM commented May 31, 2026

Copy link
Copy Markdown

Closes #30

Summary

  • Throw a clear guidance error when a route/middleware returns undefined, null, or primitive values.
  • Keep existing explicit guidance for raw object returns: use ctx.json({...}).
  • Add regression test covering undefined route returns.

Why

This avoids confusing low-level failures and points users directly to the correct response API.

Validation

  • npm test -- tests/errors/do-not-allow-raw-json.test.ts

/claim #30

@MikeGarciaAGM

Copy link
Copy Markdown
Author

Follow-up: this PR now includes /claim #30 and is ready for payout review. Validation already run locally: npm test -- tests/errors/do-not-allow-raw-json.test.ts. Happy to adjust quickly if maintainers want narrower behavior.

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.

When a user returns return { ... } from a route instead of return ctx.json({ ... }), throw an error telling them to use ctx.json

2 participants