[GH-ISSUE #5168] after updating backup codes using generateBackupCodes it gives json parse error #10178

Closed
opened 2026-04-13 06:09:07 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @Invisible-Bot-Java on GitHub (Oct 8, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/5168

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

enable 2fa on account
generate new backup codes
now when u call const data = await auth.api.viewBackupCodes({
body: {
userId: session.user.id,
},
});
u will get json parse error always

Current vs. Expected behavior

it should give backup codes as it was giving before updating backup codes but giving error instead POST /api/auth/two-factor/generate-backup-codes 200 in 5423ms
⨯ SyntaxError: Unexpected number in JSON at position 1 (line 1 column 2)
at JSON.parse ()
at async page (src\app(settings)\settings\security\backup-codes\page.tsx:33:15)
31 | }
32 |

33 | const data = await auth.api.viewBackupCodes({
| ^
34 | body: {
35 | userId: session.user.id,
36 | }, {
digest: '73072180'

What version of Better Auth are you using?

1.3.24

System info

"system": {
    "platform": "win32",
    "arch": "x64",
    "version": "Windows 11 Home Single Language",
    "release": "10.0.22635",
    "cpuCount": 4,
    "cpuModel": "AMD Ryzen 3 3250U with Radeon Graphics         ",
    "totalMemory": "5.95 GB",
    "freeMemory": "1.43 GB"
  },
  "node": {
    "version": "v24.4.1",
    "env": "development"
  },
  "packageManager": {
    "name": "bun",
    "version": "1.2.18"
  },

Which area(s) are affected? (Select all that apply)

Client

Auth config (if applicable)


Additional context

No response

Originally created by @Invisible-Bot-Java on GitHub (Oct 8, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/5168 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce enable 2fa on account generate new backup codes now when u call const data = await auth.api.viewBackupCodes({ body: { userId: session.user.id, }, }); u will get json parse error always ### Current vs. Expected behavior it should give backup codes as it was giving before updating backup codes but giving error instead POST /api/auth/two-factor/generate-backup-codes 200 in 5423ms ⨯ SyntaxError: Unexpected number in JSON at position 1 (line 1 column 2) at JSON.parse (<anonymous>) at async page (src\app\(settings)\settings\security\backup-codes\page.tsx:33:15) 31 | } 32 | > 33 | const data = await auth.api.viewBackupCodes({ | ^ 34 | body: { 35 | userId: session.user.id, 36 | }, { digest: '73072180' ### What version of Better Auth are you using? 1.3.24 ### System info ```bash "system": { "platform": "win32", "arch": "x64", "version": "Windows 11 Home Single Language", "release": "10.0.22635", "cpuCount": 4, "cpuModel": "AMD Ryzen 3 3250U with Radeon Graphics ", "totalMemory": "5.95 GB", "freeMemory": "1.43 GB" }, "node": { "version": "v24.4.1", "env": "development" }, "packageManager": { "name": "bun", "version": "1.2.18" }, ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-13 06:09:07 -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#10178