fix(core): accept string expires_in from the token endpoint - #366
Conversation
#341 started validating the token JSON with Zod and required a number. The live endpoint still sends a string, so sign-in parsed, threw, and left the user signed out. Co-authored-by: Cursor <cursoragent@cursor.com>
🦋 Changeset detectedLatest commit: d2fd328 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8982b8b89c
ℹ️ 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".
Reject null, booleans, and empty strings that z.coerce.number() turned into 0. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Idk what greppy is crying about but I like this |
0, "0", and negatives persisted an already-expired session. Co-authored-by: Cursor <cursoragent@cursor.com>
cameronapak
left a comment
There was a problem hiding this comment.
Spec
No Jira ticket. Spec is the PR body. #341 rejected string expires_in and sign-in dropped.
No must-fix. Counts: 0 must-fix. 1 question. 0 nits.
Worst issue: refresh still uses .parse() and wraps any Error. Exchange now has a dedicated invalid-response message. The spec asked for a clear parse error. It said "both" only for coerce.
Required items land. Both schemas share TokenExpiresInSchema. Exchange fixture is '3599'. Callback logs the failure. Patch changeset covers core and hooks. null, false, and '' now fail.
Standards
No must-fix. Counts: 0 must-fix. 2 questions. 1 nit.
Worst issue: console.error on the auth callback is unconditional in a published hooks package. Other SDK logs stay behind a dev gate.
The z.number() arm still admits 0 and negatives. Those persist an already-dead session. The digit-string arm does not.
Nit: exchange uses safeParse. Refresh still uses .parse(). Same lifetime field, different error shape.
Code Reviewer bot, sent on behalf of Cam.
Reject 0, negatives, and floats. Log auth callback failures only in development, matching Users.ts and client.ts. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
?code=still in the URL.Root cause
#341 (
e9840fc5) started validating/auth/tokenJSON with Zod and requiredexpires_into be a number.Before that PR, the SDK
JSON.parse’d the body and type-asserted it. A string like"3599"still worked at runtime ("3599" * 1000). After #341, Zod rejected the live payload, the exchange catch path cleared tokens, and the failure was easy to miss.The live token endpoint (and the platform docs) still send
expires_inas a string. Tests only used a numeric fixture, so CI did not catch it.Solution
expires_into a number on both the token-exchange and token-refresh schemas.Test plan
http://localhost:5173(not127.0.0.1)?code=in the URL)Greptile Summary
The PR updates token exchange and refresh validation to accept the live endpoint’s string-shaped
expires_inwhile retaining strict validation.Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Reviews (4): Last reviewed commit: "fix: require positive integer expires_in..." | Re-trigger Greptile
Context used (4)