Skip to content

Improve primitive route return guidance#151

Closed
JacKane21 wants to merge 2 commits into
tscircuit:mainfrom
JacKane21:codex/primitive-route-return-guidance-30
Closed

Improve primitive route return guidance#151
JacKane21 wants to merge 2 commits into
tscircuit:mainfrom
JacKane21:codex/primitive-route-return-guidance-30

Conversation

@JacKane21
Copy link
Copy Markdown

Summary

  • catches invalid primitive route returns before response serialization tries to inspect them
  • reuses the existing ctx.json(...) guidance for raw object and primitive return mistakes
  • adds regression coverage for raw string, number, boolean, and bigint returns while keeping valid Response/ctx.json(...) flows unchanged

/claim #30

Validation

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

Note

npm test -- tests/errors/do-not-allow-raw-json.test.ts currently stops in the package pretest build on pre-existing OpenAPI codegen TypeScript errors (operation.responses possibly undefined) before this test file runs.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b4c56efce7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/create-with-winter-spec.ts Outdated
: rawResponse.status
: rawResponse instanceof Response
? rawResponse.status
: 200
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve SerializableToResponse handling for non-WinterSpec types

Setting the fallback status to 200 here makes every non-Response/non-WinterSpecResponse return look successful, which sends custom SerializableToResponse objects into the validating path; serializeToResponse(...) then throws Unknown Response type for those objects because it only accepts WinterSpecResponse subclasses when validation is on. This is a regression for middleware/route handlers that return their own SerializableToResponse implementations (a supported type in Middleware/WinterSpecRouteFn) that previously serialized successfully.

Useful? React with 👍 / 👎.

@JacKane21 JacKane21 force-pushed the codex/primitive-route-return-guidance-30 branch from a1e1d09 to 1573fbc Compare May 22, 2026 13:06
@JacKane21
Copy link
Copy Markdown
Author

Closing this out as part of wrapping up my bounty/OSS cleanup. Thanks for the time and review.

@JacKane21 JacKane21 closed this May 26, 2026
@JacKane21 JacKane21 deleted the codex/primitive-route-return-guidance-30 branch May 26, 2026 04:16
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