[GH-ISSUE #6552] Breaking change from v1.4.4 -> v1.4.5 #19182

Closed
opened 2026-04-15 17:59:42 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @demitrin on GitHub (Dec 5, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/6552

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Backwards incompatible change introduced by this change: fd7256014b

  1. use prisma and any additional field with string[] and prisma schema type String[]
  2. see that when writing to prisma, we get a stringified json instead of the json. which breaks the shape when writing to the db

Current vs. Expected behavior

I would expect that we can still write to additional fields with type string[] and prisma schema type String[]

What version of Better Auth are you using?

1.4.5

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6041",
    "release": "24.6.0",
    "cpuCount": 14,
    "cpuModel": "Apple M4 Max",
    "totalMemory": "36.00 GB",
    "freeMemory": "0.85 GB"
  },
  "node": {
    "version": "v24.4.1",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.4.2"
  },
  "frameworks": [
    {
      "name": "fastify",
      "version": "^5.6.0"
    }
  ],
  "databases": [
    {
      "name": "pg",
      "version": "^8.16.2"
    },
    {
      "name": "@prisma/client",
      "version": "^7.0.1"
    }
  ],

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

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  plugins: [
    organization({
      schema: {
          additionalFields: {
            fakeStringArrayField: {
              type: 'string[]',
              input: true,
              required: true,
            },
          },
        },
      },
    }),
});

Additional context

No response

Originally created by @demitrin on GitHub (Dec 5, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/6552 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Backwards incompatible change introduced by this change: https://github.com/better-auth/better-auth/commit/fd7256014beb9ee2da225e26e6bce5ef2c0f7761 1. use prisma and any additional field with `string[]` and prisma schema type `String[]` 2. see that when writing to prisma, we get a stringified json instead of the json. which breaks the shape when writing to the db ### Current vs. Expected behavior I would expect that we can still write to additional fields with type `string[]` and prisma schema type `String[]` ### What version of Better Auth are you using? 1.4.5 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6041", "release": "24.6.0", "cpuCount": 14, "cpuModel": "Apple M4 Max", "totalMemory": "36.00 GB", "freeMemory": "0.85 GB" }, "node": { "version": "v24.4.1", "env": "development" }, "packageManager": { "name": "npm", "version": "11.4.2" }, "frameworks": [ { "name": "fastify", "version": "^5.6.0" } ], "databases": [ { "name": "pg", "version": "^8.16.2" }, { "name": "@prisma/client", "version": "^7.0.1" } ], ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ plugins: [ organization({ schema: { additionalFields: { fakeStringArrayField: { type: 'string[]', input: true, required: true, }, }, }, }, }), }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-15 17:59:42 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Dec 5, 2025):

Hi there! Thanks for reporting this breaking change. Based on the details provided, it appears that in v1.4.5 the serialization for additional fields—specifically for those with type string[] when used with Prisma—has changed. Instead of writing a JSON object directly, the value ends up being stringified, which causes a mismatch with the expected Prisma schema for String[]. This behavior wasn’t present in v1.4.4.

As a next step, you might consider temporarily reverting to v1.4.4 if your deployment is blocked while we investigate a fix. Additionally, please check that your field definition matches the documentation for array types in our plugin schema. We’re also reviewing the recent changes to narrow down the root cause.

Could you let us know if a workaround (like manually converting the string back to an array before the database write) helps for now? Tag @better-auth-agent if you would like an answer from the Agent.

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3618599486 --> @better-auth-agent[bot] commented on GitHub (Dec 5, 2025): Hi there! Thanks for reporting this breaking change. Based on the details provided, it appears that in v1.4.5 the serialization for additional fields—specifically for those with type string[] when used with Prisma—has changed. Instead of writing a JSON object directly, the value ends up being stringified, which causes a mismatch with the expected Prisma schema for String[]. This behavior wasn’t present in v1.4.4. As a next step, you might consider temporarily reverting to v1.4.4 if your deployment is blocked while we investigate a fix. Additionally, please check that your field definition matches the documentation for array types in our plugin schema. We’re also reviewing the recent changes to narrow down the root cause. Could you let us know if a workaround (like manually converting the string back to an array before the database write) helps for now? Tag @better-auth-agent if you would like an answer from the Agent. _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@dosubot[bot] commented on GitHub (Dec 5, 2025):

Hi @demitrin! I'm Dosu and I’m helping the better-auth team.

This change in v1.4.5 is intentional: when the adapter config has supportsJSON: false, Better Auth now serializes array fields like string[] and number[] as stringified JSON before saving to the database, and parses them back when reading. This is meant to ensure compatibility with databases that don't support native JSON or array types, but it can break shape expectations for Prisma, which expects native arrays for fields like String[] in your schema. You can avoid this by setting supportsJSON: true in your adapter config if your database (like Postgres with Prisma) supports native arrays—this will store arrays as expected and prevent the stringification issue. See the adapter factory code and docs for details: adapter factory implementation, custom adapter guide.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3618605991 --> @dosubot[bot] commented on GitHub (Dec 5, 2025): <!-- Greeting --> Hi @demitrin! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This change in v1.4.5 is intentional: when the adapter config has `supportsJSON: false`, Better Auth now serializes array fields like `string[]` and `number[]` as stringified JSON before saving to the database, and parses them back when reading. This is meant to ensure compatibility with databases that don't support native JSON or array types, but it can break shape expectations for Prisma, which expects native arrays for fields like `String[]` in your schema. You can avoid this by setting `supportsJSON: true` in your adapter config if your database (like Postgres with Prisma) supports native arrays—this will store arrays as expected and prevent the stringification issue. See the adapter factory code and docs for details: [adapter factory implementation](https://github.com/better-auth/better-auth/blob/be00f10cad5bbad5a0dababa4b836a3d95ce7747/packages/core/src/db/adapter/factory.ts#L63-L822), [custom adapter guide](https://github.com/better-auth/better-auth/blob/be00f10cad5bbad5a0dababa4b836a3d95ce7747/docs/content/docs/guides/create-a-db-adapter.mdx#L438-L606). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/746f2ba0-69a3-450b-b013-40068179ed05?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/746f2ba0-69a3-450b-b013-40068179ed05?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/746f2ba0-69a3-450b-b013-40068179ed05?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/746f2ba0-69a3-450b-b013-40068179ed05?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/746f2ba0-69a3-450b-b013-40068179ed05?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/746f2ba0-69a3-450b-b013-40068179ed05?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/746f2ba0-69a3-450b-b013-40068179ed05?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20change%20in%20v1.4.5%20is%20intentional%3A%20when%20the%20adapter%20config%20has%20%60supportsJSON%3A%20false%60%2C%20Better%20Auth%20now%20serializes%20array%20fields%20like%20%60string%5B%5D%60%20and%20%60number%5B%5D%60%20as%20stringified%20JSON%20before%20saving%20to%20the%20database%2C%20and%20parses%20them%20back%20when%20reading.%20This%20is%20meant%20to%20ensure%20compatibility%20with%20databases%20that%20don%27t%20support%20native%20JSON%20or%20array%20types%2C%20but%20it%20can%20break%20shape%20expectations%20for%20Prisma%2C%20which%20expects%20native%20arrays%20for%20fields%20like%20%60String%5B%5D%60%20in%20your%20schema.%20You%20can%20avoid%20this%20by%20setting%20%60supportsJSON%3A%20true%60%20in%20your%20adapter%20config%20if%20your%20database%20%28like%20Postgres%20with%20Prisma%29%20supports%20native%20arrays%E2%80%94this%20will%20store%20arrays%20as%20expected%20and%20prevent%20the%20stringification%20issue.%20See%20the%20adapter%20factory%20code%20and%20docs%20for%20details%3A%20%5Badapter%20factory%20implementation%5D%28https%3A//github.com/better-auth/better-auth/blob/be00f10cad5bbad5a0dababa4b836a3d95ce7747/packages/core/src/db/adapter/factory.ts%23L63-L822%29%2C%20%5Bcustom%20adapter%20guide%5D%28https%3A//github.com/better-auth/better-auth/blob/be00f10cad5bbad5a0dababa4b836a3d95ce7747/docs/content/docs/guides/create-a-db-adapter.mdx%23L438-L606%29.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/6552)
Author
Owner

@demitrin commented on GitHub (Dec 5, 2025):

Unless im mistaken, Better auth don't allow setting supportsJSON when creating the prisma adapter. If anything, you should ideally make the default prisma adapter properly set supportsJSON: true

<!-- gh-comment-id:3618614568 --> @demitrin commented on GitHub (Dec 5, 2025): Unless im mistaken, Better auth don't allow setting `supportsJSON` when creating the prisma adapter. If anything, you should ideally make the default prisma adapter properly set `supportsJSON: true`
Author
Owner

@dosubot[bot] commented on GitHub (Dec 5, 2025):

You're correct—the Prisma adapter in Better Auth does not currently let you set supportsJSON manually, and it defaults to false internally. This means array fields like string[] are stringified as JSON before being stored, which breaks shape expectations for Prisma's native array types. The adapter factory supports a supportsJSON flag, but the Prisma adapter's config doesn't expose it, so users can't override the default without modifying the adapter code or forking it themselves. Ideally, the Prisma adapter should set supportsJSON: true by default for databases like Postgres that support native arrays and JSON types. This would resolve the serialization issue for array fields in Prisma schemas. For reference, see the adapter factory config handling here and the Prisma adapter implementation here.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3618620796 --> @dosubot[bot] commented on GitHub (Dec 5, 2025): <!-- Answer --> You're correct—the Prisma adapter in Better Auth does not currently let you set `supportsJSON` manually, and it defaults to `false` internally. This means array fields like `string[]` are stringified as JSON before being stored, which breaks shape expectations for Prisma's native array types. The adapter factory supports a `supportsJSON` flag, but the Prisma adapter's config doesn't expose it, so users can't override the default without modifying the adapter code or forking it themselves. Ideally, the Prisma adapter should set `supportsJSON: true` by default for databases like Postgres that support native arrays and JSON types. This would resolve the serialization issue for array fields in Prisma schemas. For reference, see the adapter factory config handling [`here`](https://github.com/better-auth/better-auth/blob/be00f10cad5bbad5a0dababa4b836a3d95ce7747/packages/core/src/db/adapter/factory.ts#L59-L766) and the Prisma adapter implementation [`here`](https://github.com/better-auth/better-auth/blob/be00f10cad5bbad5a0dababa4b836a3d95ce7747/packages/better-auth/src/adapters/prisma-adapter/prisma-adapter.ts#L13-L437). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/7a55d688-f959-4491-bab0-f9727557594d?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/7a55d688-f959-4491-bab0-f9727557594d?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/7a55d688-f959-4491-bab0-f9727557594d?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/7a55d688-f959-4491-bab0-f9727557594d?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/7a55d688-f959-4491-bab0-f9727557594d?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/7a55d688-f959-4491-bab0-f9727557594d?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/7a55d688-f959-4491-bab0-f9727557594d?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=You%27re%20correct%E2%80%94the%20Prisma%20adapter%20in%20Better%20Auth%20does%20not%20currently%20let%20you%20set%20%60supportsJSON%60%20manually%2C%20and%20it%20defaults%20to%20%60false%60%20internally.%20This%20means%20array%20fields%20like%20%60string%5B%5D%60%20are%20stringified%20as%20JSON%20before%20being%20stored%2C%20which%20breaks%20shape%20expectations%20for%20Prisma%27s%20native%20array%20types.%20The%20adapter%20factory%20supports%20a%20%60supportsJSON%60%20flag%2C%20but%20the%20Prisma%20adapter%27s%20config%20doesn%27t%20expose%20it%2C%20so%20users%20can%27t%20override%20the%20default%20without%20modifying%20the%20adapter%20code%20or%20forking%20it%20themselves.%20Ideally%2C%20the%20Prisma%20adapter%20should%20set%20%60supportsJSON%3A%20true%60%20by%20default%20for%20databases%20like%20Postgres%20that%20support%20native%20arrays%20and%20JSON%20types.%20This%20would%20resolve%20the%20serialization%20issue%20for%20array%20fields%20in%20Prisma%20schemas.%20For%20reference%2C%20see%20the%20adapter%20factory%20config%20handling%20%5B%60here%60%5D%28https%3A//github.com/better-auth/better-auth/blob/be00f10cad5bbad5a0dababa4b836a3d95ce7747/packages/core/src/db/adapter/factory.ts%23L59-L766%29%20and%20the%20Prisma%20adapter%20implementation%20%5B%60here%60%5D%28https%3A//github.com/better-auth/better-auth/blob/be00f10cad5bbad5a0dababa4b836a3d95ce7747/packages/better-auth/src/adapters/prisma-adapter/prisma-adapter.ts%23L13-L437%29.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/6552)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#19182