[PR #7991] [MERGED] fix(captcha): include error codes in middleware responses #7671

Closed
opened 2026-03-13 13:45:10 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7991
Author: @himself65
Created: 2/16/2026
Status: Merged
Merged: 2/16/2026
Merged by: @himself65

Base: canaryHead: himself65/2026/02/16/fix


📝 Commits (1)

  • 2b8ae71 fix(captcha): include error codes in middleware responses

📊 Changes

6 files changed (+9 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/plugins/captcha/index.ts (+2 -0)
📝 packages/better-auth/src/plugins/captcha/verify-handlers/captchafox.ts (+1 -0)
📝 packages/better-auth/src/plugins/captcha/verify-handlers/cloudflare-turnstile.ts (+1 -0)
📝 packages/better-auth/src/plugins/captcha/verify-handlers/google-recaptcha.ts (+1 -0)
📝 packages/better-auth/src/plugins/captcha/verify-handlers/h-captcha.ts (+1 -0)
📝 packages/better-auth/src/utils/middleware-response.ts (+3 -1)

📄 Description

Fixes: https://github.com/better-auth/better-auth/issues/7969


Summary by cubic

Include error codes in all captcha middleware responses so clients can reliably handle failures. The JSON body now returns message and code across all providers.

  • Bug Fixes
    • middlewareResponse now accepts and returns code in the response body.
    • All captcha handlers send specific codes: MISSING_RESPONSE (400), VERIFICATION_FAILED (403 for CaptchaFox, Cloudflare Turnstile, Google reCAPTCHA, hCaptcha), and UNKNOWN_ERROR (500).

Written for commit 2b8ae7194b. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7991 **Author:** [@himself65](https://github.com/himself65) **Created:** 2/16/2026 **Status:** ✅ Merged **Merged:** 2/16/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2026/02/16/fix` --- ### 📝 Commits (1) - [`2b8ae71`](https://github.com/better-auth/better-auth/commit/2b8ae7194b49034fb74ab2b0d4523ef04f4945d9) fix(captcha): include error codes in middleware responses ### 📊 Changes **6 files changed** (+9 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/captcha/index.ts` (+2 -0) 📝 `packages/better-auth/src/plugins/captcha/verify-handlers/captchafox.ts` (+1 -0) 📝 `packages/better-auth/src/plugins/captcha/verify-handlers/cloudflare-turnstile.ts` (+1 -0) 📝 `packages/better-auth/src/plugins/captcha/verify-handlers/google-recaptcha.ts` (+1 -0) 📝 `packages/better-auth/src/plugins/captcha/verify-handlers/h-captcha.ts` (+1 -0) 📝 `packages/better-auth/src/utils/middleware-response.ts` (+3 -1) </details> ### 📄 Description Fixes: https://github.com/better-auth/better-auth/issues/7969 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Include error codes in all captcha middleware responses so clients can reliably handle failures. The JSON body now returns message and code across all providers. - **Bug Fixes** - middlewareResponse now accepts and returns code in the response body. - All captcha handlers send specific codes: MISSING_RESPONSE (400), VERIFICATION_FAILED (403 for CaptchaFox, Cloudflare Turnstile, Google reCAPTCHA, hCaptcha), and UNKNOWN_ERROR (500). <sup>Written for commit 2b8ae7194b49034fb74ab2b0d4523ef04f4945d9. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:45:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#7671