Skip to content

test(open-api): lock in requestBody for /phone-number/verify - #11208

Merged
bytaesu merged 3 commits into
better-auth:mainfrom
devtechedge:test/openapi-phone-number-verify-8122
Sep 9, 2026
Merged

bytaesu merged 3 commits into
better-auth:mainfrom
devtechedge:test/openapi-phone-number-verify-8122

Conversation

@devtechedge

@devtechedge devtechedge commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes #8122

Summary

/phone-number/verify dropped its OpenAPI requestBody after v1.4.19. The body schema is z.object({…}).and(z.record(z.string(), z.any())) so additional user fields can pass through signUpOnVerification. The generator had no ZodIntersection handler, so instanceof ZodObject was false and the body was omitted from the spec.

Runtime was never broken. Generated clients were: swift-openapi-generator produced a verify function with no parameters.

On current main (1.7.3) the generator already flattens object+record intersections. /sign-in/email-otp uses the same .and(z.record()) pattern and already has coverage. This PR does not retouch the generator. It adds the reported phone-number endpoint as a regression so #8122 cannot silently come back.

Problem (from #8122)

Repro from the issue, still the schema on main:

const verifyPhoneNumberBodySchema = z
  .object({
    phoneNumber: z.string(),
    code: z.string(),
    disableSession: z.boolean().optional(),
    updatePhoneNumber: z.boolean().optional(),
  })
  .and(z.record(z.string(), z.any()));

Expected: POST /phone-number/verify emits requestBody with required phoneNumber and code.
v1.4.19 / v1.6.26: requestBody missing. /phone-number/send-otp stayed intact because it is a plain z.object.

Confirmed on v1.6.26 (6 Aug). Previous attempt: #9472 (same root cause, closed unmerged 13 May, no review). @pupuking723 claimed it verbally on 23 Aug with no PR since.

What this PR adds

packages/better-auth/src/plugins/open-api/open-api.test.ts only.

  1. Boot openAPI() + phoneNumber({ sendOTP, signUpOnVerification }) — same options as the original repro.
  2. Assert every phone-number POST path has a requestBody:
    • /sign-in/phone-number
    • /phone-number/send-otp
    • /phone-number/verify
    • /phone-number/request-password-reset
    • /phone-number/reset-password
  3. Focused phone-number plugin: OpenAPI spec missing requestBody for /phone-number/verify in v1.4.19 #8122 case on /phone-number/verify:
    • requestBody.required === true
    • type: "object"
    • required: phoneNumber, code
    • optional: disableSession, updatePhoneNumber (boolean, not in required)
    • additionalProperties: {} — the .and(z.record(z.string(), z.any())) extra-keys contract, matching the existing email-otp assertion

No production code. No changeset.

Verification

pnpm vitest packages/better-auth/src/plugins/open-api/open-api.test.ts --run

32 passed, including the two new phone-number cases. Biome + cspell clean on the commit.

Related

Agent disclosure

Written by an AI agent on behalf of @devtechedge, who has reviewed this pull request.


Summary by cubic

Adds regression tests for the OpenAPI requestBody on phone-number POST endpoints, locking in the /phone-number/verify body that was missing from generated specs since v1.4.19. The bug came from the generator not handling ZodIntersection, but runtime was never affected. No production code changes; the tests assert required fields, optional fields, and the additionalProperties contract, closing #8122.

Written for commit 5e44d9f. Summary will update on new commits.

Review in cubic

The OpenAPI generator already flattens object+record intersections
(the v1.4.19 regression from #8122). Add a focused regression for the
reported phone-number verify endpoint, matching the email-otp coverage.

Closes #8122
@devtechedge
devtechedge requested a review from a team as a code owner September 7, 2026 20:35
@devtechedge
devtechedge requested review from Bekacru and removed request for a team September 7, 2026 20:35
@vercel

vercel Bot commented Sep 7, 2026

Copy link
Copy Markdown

@devtechedge is attempting to deploy a commit to the better-auth Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
better-auth Skipped Skipped Sep 8, 2026 10:46am UTC

@better-release better-release Bot added the devtools CLI, OpenAPI, telemetry, i18n, test-utils label Sep 7, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds regression coverage for OpenAPI request bodies generated by the phone-number plugin.

  • Verifies that each configured phone-number POST endpoint exposes a request body.
  • Locks in the required and optional fields for /phone-number/verify.
  • Preserves coverage for arbitrary additional verification fields represented by additionalProperties.

Confidence Score: 5/5

The PR appears safe to merge because it only adds regression tests that accurately reflect the existing phone-number OpenAPI contract.

No actionable new issues or outstanding repository-rule violations were identified.

Reviews (3): Last reviewed commit: "test(open-api): strengthen phone number ..." | Re-trigger Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 1 file (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

@pkg-pr-new

pkg-pr-new Bot commented Sep 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

@better-auth/api-key

npm i https://pkg.pr.new/@better-auth/api-key@11208

better-auth

npm i https://pkg.pr.new/better-auth@11208

@better-auth/cimd

npm i https://pkg.pr.new/@better-auth/cimd@11208

auth

npm i https://pkg.pr.new/auth@11208

@better-auth/core

npm i https://pkg.pr.new/@better-auth/core@11208

@better-auth/drizzle-adapter

npm i https://pkg.pr.new/@better-auth/drizzle-adapter@11208

@better-auth/electron

npm i https://pkg.pr.new/@better-auth/electron@11208

@better-auth/expo

npm i https://pkg.pr.new/@better-auth/expo@11208

@better-auth/i18n

npm i https://pkg.pr.new/@better-auth/i18n@11208

@better-auth/kysely-adapter

npm i https://pkg.pr.new/@better-auth/kysely-adapter@11208

@better-auth/mcp

npm i https://pkg.pr.new/@better-auth/mcp@11208

@better-auth/memory-adapter

npm i https://pkg.pr.new/@better-auth/memory-adapter@11208

@better-auth/mongo-adapter

npm i https://pkg.pr.new/@better-auth/mongo-adapter@11208

@better-auth/oauth-provider

npm i https://pkg.pr.new/@better-auth/oauth-provider@11208

@better-auth/passkey

npm i https://pkg.pr.new/@better-auth/passkey@11208

@better-auth/prisma-adapter

npm i https://pkg.pr.new/@better-auth/prisma-adapter@11208

@better-auth/redis-storage

npm i https://pkg.pr.new/@better-auth/redis-storage@11208

@better-auth/scim

npm i https://pkg.pr.new/@better-auth/scim@11208

@better-auth/sso

npm i https://pkg.pr.new/@better-auth/sso@11208

@better-auth/stripe

npm i https://pkg.pr.new/@better-auth/stripe@11208

@better-auth/telemetry

npm i https://pkg.pr.new/@better-auth/telemetry@11208

@better-auth/test-utils

npm i https://pkg.pr.new/@better-auth/test-utils@11208

commit: 5e44d9f

@devtechedge

Copy link
Copy Markdown
Contributor Author

Thanks @bytaesu - the tighter additionalProperties check and the all-paths requestBody loop are better than what I landed. Appreciate you taking that on this PR.

@bytaesu bytaesu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you @devtechedge

LGTM!

@bytaesu bytaesu added the skip-changeset No changeset required for this PR label Sep 9, 2026
@bytaesu
bytaesu added this pull request to the merge queue Sep 9, 2026
Merged via the queue into better-auth:main with commit 874752f Sep 9, 2026
38 of 41 checks passed
@devtechedge

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing and merging this, @bytaesu.

Glad #8122 is closed. Runtime on /phone-number/verify was never broken; the missing OpenAPI requestBody after v1.4.19 was what broke generated clients.

Locking the reported endpoint (and the rest of the phone-number POST paths) next to the existing email-otp coverage should keep that from coming back quietly.

Appreciate you taking the time on a tests-only PR!

devtechedge added a commit to devtechedge/oss-contributions that referenced this pull request Sep 10, 2026
…erge, prettier skip

- Merged: add better-auth/better-auth#11208 (merged 9 Sep 2026 08:19:43 UTC)
  Previously misfiled under Pipeline as 'merged upstream; historical context'.
- Closed (not merged): add Kludex/starlette#3533 (closed by author, competing
  PRs #3529/#3531 already covered it) - row was missing entirely.
- Pipeline: add prettier/prettier#19985 (already fixed upstream by #19838 on
  15 Aug 2026; closed 10 Sep 2026 via test-only #20020). Comments only, no PR.
- Pipeline: drop better-auth#11208 now that it is counted in Merged.
- Totals corrected 18->20 external PRs; merged badge 5->6; closed 4->5.
Verified against live GitHub API: 9 open / 6 merged / 5 closed.
devtechedge added a commit to devtechedge/oss-contributions that referenced this pull request Sep 12, 2026
…erge, prettier skip

- Merged: add better-auth/better-auth#11208 (merged 9 Sep 2026 08:19:43 UTC)
  Previously misfiled under Pipeline as 'merged upstream; historical context'.
- Closed (not merged): add Kludex/starlette#3533 (closed by author, competing
  PRs #3529/#3531 already covered it) - row was missing entirely.
- Pipeline: add prettier/prettier#19985 (already fixed upstream by #19838 on
  15 Aug 2026; closed 10 Sep 2026 via test-only #20020). Comments only, no PR.
- Pipeline: drop better-auth#11208 now that it is counted in Merged.
- Totals corrected 18->20 external PRs; merged badge 5->6; closed 4->5.
Verified against live GitHub API: 9 open / 6 merged / 5 closed.
@better-release better-release Bot added the locked Locked conversations after being closed for 7 days label Sep 17, 2026
@better-release better-release Bot locked as resolved and limited conversation to collaborators Sep 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

devtools CLI, OpenAPI, telemetry, i18n, test-utils locked Locked conversations after being closed for 7 days skip-changeset No changeset required for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

phone-number plugin: OpenAPI spec missing requestBody for /phone-number/verify in v1.4.19

2 participants