[GH-ISSUE #3104] Exception raised when providing metadata field to createOrganization #9475

Closed
opened 2026-04-13 04:57:06 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @frankhillard on GitHub (Jun 20, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3104

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

What syntax is required for metadata parameter of createOrganization ?

I call createOrganization function without metadata parameter, everything's works fine.

When I provide the metadata field as parameter, I get a raised exception:
JSON Parse error: Unexpected identifier \"object\".
But the organization seems created.
Since metadata is supposed to be a Record<string, any> so I provided { field: "value"} to test.

const organization = await auth.api.createOrganization({
    body: {
        name: "name",
        slug: "orgSlug",
        metadata: { field: "value" },
    },
});

Current vs. Expected behavior

The createOrganization call raises an exception despite really creating the organization. This is probably due to a wrong format of metadata parameter.

What version of Better Auth are you using?

1.2.9

Provide environment information

ubuntu, pnpm, hono

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

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @frankhillard on GitHub (Jun 20, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3104 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce What syntax is required for metadata parameter of `createOrganization` ? I call `createOrganization` function without `metadata` parameter, everything's works fine. When I provide the `metadata` field as parameter, I get a raised exception: `JSON Parse error: Unexpected identifier \"object\"`. But the organization seems created. Since `metadata` is supposed to be a `Record<string, any>` so I provided `{ field: "value"}` to test. ``` const organization = await auth.api.createOrganization({ body: { name: "name", slug: "orgSlug", metadata: { field: "value" }, }, }); ``` ### Current vs. Expected behavior The createOrganization call raises an exception despite really creating the organization. This is probably due to a wrong format of `metadata` parameter. ### What version of Better Auth are you using? 1.2.9 ### Provide environment information ```bash ubuntu, pnpm, hono ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-13 04:57:06 -05:00
Author
Owner

@Kinfe123 commented on GitHub (Jun 26, 2025):

is this the actual metadata you have tried it with ?

metadata: { field: "value" },
<!-- gh-comment-id:3007328460 --> @Kinfe123 commented on GitHub (Jun 26, 2025): is this the actual metadata you have tried it with ? ```ts metadata: { field: "value" }, ```
Author
Owner

@Kinfe123 commented on GitHub (Aug 21, 2025):

This should be working fine and make sure to updat e it to latest or provide me more info for reproducing it.

<!-- gh-comment-id:3211928737 --> @Kinfe123 commented on GitHub (Aug 21, 2025): This should be working fine and make sure to updat e it to latest or provide me more info for reproducing it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9475