1.3.10 and later does not work on zod 3 projects #2000

Closed
opened 2026-03-13 09:20:01 -05:00 by GiteaMirror · 11 comments
Owner

Originally created by @jippi on GitHub (Sep 23, 2025).

Originally assigned to: @himself65 on GitHub.

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Seeing the issue also mentioned in https://github.com/better-auth/better-auth/issues/4757#issuecomment-3322314480

2025-09-23T03:40:09.339Z ERROR [Better Auth]: [#better-auth]: Couldn't read your auth config. TypeError: z.coerce.boolean(...).meta is not a function
    at file:///Users/nadilas/workspace/.../node_modules/better-auth/dist/shared/better-auth.CBY7cUGy.mjs:61:44


const getSessionQuerySchema = z.optional(
  z.object({
    /**
     * If cookie cache is enabled, it will disable the cache
     * and fetch the session from the database
     */
>>>>    disableCookieCache: z.coerce.boolean().meta({
      description: "Disable cookie cache and fetch session from database"
    }).optional(),
    disableRefresh: z.coerce.boolean().meta({
      description: "Disable session refresh. Useful for checking session status, without updating the session"
    }).optional()
  })
);

This happen when using Zod 3 in the root project for me. I'm not ready to move to Zod 4 yet, but would like to keep up to date with better-auth.

Current vs. Expected behavior

See description

What version of Better Auth are you using?

1.3.10 and later

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.0.0: Mon Aug 25 21:17:51 PDT 2025; root:xnu-12377.1.9~3/RELEASE_ARM64_T6000",
    "release": "25.0.0",
    "cpuCount": 8,
    "cpuModel": "Apple M1 Pro",
    "totalMemory": "16.00 GB",
    "freeMemory": "0.12 GB"
  },
  "node": {
    "version": "v23.11.0",
    "env": "local"
  },
  "packageManager": {
    "name": "npm",
    "version": "10.9.2"
  },
  "frameworks": [
    {
      "name": "svelte",
      "version": "^5.26.3"
    },
    {
      "name": "@sveltejs/kit",
      "version": "^2.20.3"
    }
  ],
  "databases": [
    {
      "name": "pg",
      "version": "^8.12.0"
    }
  ],
  "betterAuth": {
    "version": "^1.3.9",
    "config": {
      "appName": "MangaBaka.dev",
      "basePath": "/auth",
      "disabledPaths": [
        "/admin/ban-user",
        "/admin/impersonate-user",
        "/admin/list-user-sessions",
        "/admin/remove-user",
        "/admin/revoke-user-session",
        "/admin/revoke-user-sessions",
        "/admin/set-user-password",
        "/admin/stop-impersonating",
        "/admin/unban-user",
        "/change-email",
        "/change-password",
        "/delete-user",
        "/delete-user/callback",
        "/forget-password",
        "/request-password-reset",
        "/reset-password",
        "/reset-password/:token",
        "/send-verification-email",
        "/sign-in/email",
        "/sign-in/username",
        "/sign-up/email",
        "/verify-email"
      ],
      "telemetry": {
        "enabled": false
      },
      "socialProviders": {
        "discord": {
          "enabled": true,
          "clientId": "[REDACTED]",
          "clientSecret": "[REDACTED]"
        },
        "google": {
          "enabled": true,
          "clientId": "[REDACTED]",
          "clientSecret": "[REDACTED]"
        },
        "microsoft": {
          "enabled": true,
          "clientId": "[REDACTED]",
          "clientSecret": "[REDACTED]"
        }
      },
      "baseURL": "http://localhost:5173",
      "plugins": [
        {
          "name": "open-api",
          "config": {
            "id": "open-api",
            "endpoints": {}
          }
        },
        {
          "name": "api-key",
          "config": {
            "id": "api-key",
            "$ERROR_CODES": {
              "INVALID_METADATA_TYPE": "metadata must be an object or undefined",
              "REFILL_AMOUNT_AND_INTERVAL_REQUIRED": "refillAmount is required when refillInterval is provided",
              "REFILL_INTERVAL_AND_AMOUNT_REQUIRED": "refillInterval is required when refillAmount is provided",
              "USER_BANNED": "User is banned",
              "UNAUTHORIZED_SESSION": "Unauthorized or invalid session",
              "KEY_NOT_FOUND": "API Key not found",
              "KEY_DISABLED": "API Key is disabled",
              "KEY_EXPIRED": "API Key has expired",
              "USAGE_EXCEEDED": "API Key has reached its usage limit",
              "KEY_NOT_RECOVERABLE": "API Key is not recoverable",
              "EXPIRES_IN_IS_TOO_SMALL": "The expiresIn is smaller than the predefined minimum value.",
              "EXPIRES_IN_IS_TOO_LARGE": "The expiresIn is larger than the predefined maximum value.",
              "INVALID_REMAINING": "The remaining count is either too large or too small.",
              "INVALID_PREFIX_LENGTH": "The prefix length is either too large or too small.",
              "INVALID_NAME_LENGTH": "The name length is either too large or too small.",
              "METADATA_DISABLED": "Metadata is disabled.",
              "RATE_LIMIT_EXCEEDED": "Rate limit exceeded.",
              "NO_VALUES_TO_UPDATE": "No values to update.",
              "KEY_DISABLED_EXPIRATION": "Custom key expiration values are disabled.",
              "INVALID_API_KEY": "Invalid API key.",
              "INVALID_USER_ID_FROM_API_KEY": "The user id from the API key is invalid.",
              "INVALID_API_KEY_GETTER_RETURN_TYPE": "API Key getter returned an invalid key type. Expected string.",
              "SERVER_ONLY_PROPERTY": "The property you're trying to set can only be set from the server auth instance only.",
              "FAILED_TO_UPDATE_API_KEY": "Failed to update API key",
              "NAME_REQUIRED": "API Key name is required."
            },
            "hooks": {
              "before": [
                {}
              ]
            },
            "endpoints": {},
            "schema": {
              "apikey": {
                "fields": {
                  "name": {
                    "type": "string",
                    "required": false,
                    "input": false
                  },
                  "start": {
                    "type": "string",
                    "required": false,
                    "input": false
                  },
                  "prefix": {
                    "type": "string",
                    "required": false,
                    "input": false
                  },
                  "key": {
                    "type": "string",
                    "required": true,
                    "input": false
                  },
                  "userId": {
                    "type": "string",
                    "references": {
                      "model": "user",
                      "field": "id"
                    },
                    "required": true,
                    "input": false
                  },
                  "refillInterval": {
                    "type": "number",
                    "required": false,
                    "input": false
                  },
                  "refillAmount": {
                    "type": "number",
                    "required": false,
                    "input": false
                  },
                  "lastRefillAt": {
                    "type": "date",
                    "required": false,
                    "input": false
                  },
                  "enabled": {
                    "type": "boolean",
                    "required": false,
                    "input": false,
                    "defaultValue": true
                  },
                  "rateLimitEnabled": {
                    "type": "boolean",
                    "required": false,
                    "input": false,
                    "defaultValue": true
                  },
                  "rateLimitTimeWindow": {
                    "type": "number",
                    "required": false,
                    "input": false,
                    "defaultValue": 86400000
                  },
                  "rateLimitMax": {
                    "type": "number",
                    "required": false,
                    "input": false,
                    "defaultValue": 10
                  },
                  "requestCount": {
                    "type": "number",
                    "required": false,
                    "input": false,
                    "defaultValue": 0
                  },
                  "remaining": {
                    "type": "number",
                    "required": false,
                    "input": false
                  },
                  "lastRequest": {
                    "type": "date",
                    "required": false,
                    "input": false
                  },
                  "expiresAt": {
                    "type": "date",
                    "required": false,
                    "input": false
                  },
                  "createdAt": {
                    "type": "date",
                    "required": true,
                    "input": false
                  },
                  "updatedAt": {
                    "type": "date",
                    "required": true,
                    "input": false
                  },
                  "permissions": {
                    "type": "string",
                    "required": false,
                    "input": false
                  },
                  "metadata": {
                    "type": "string",
                    "required": false,
                    "input": true,
                    "transform": {}
                  }
                },
                "modelName": "auth_api_keys"
              }
            }
          }
        },
        {
          "name": "username",
          "config": {
            "id": "username",
            "endpoints": {},
            "schema": {
              "user": {
                "fields": {
                  "username": {
                    "type": "string",
                    "required": false,
                    "sortable": true,
                    "unique": true,
                    "returned": true,
                    "transform": {}
                  },
                  "displayUsername": {
                    "type": "string",
                    "required": false,
                    "transform": {}
                  }
                }
              }
            },
            "hooks": {
              "before": [
                {},
                {}
              ]
            },
            "$ERROR_CODES": {
              "INVALID_USERNAME_OR_PASSWORD": "[REDACTED]",
              "EMAIL_NOT_VERIFIED": "Email not verified",
              "UNEXPECTED_ERROR": "Unexpected error",
              "USERNAME_IS_ALREADY_TAKEN": "Username is already taken. Please try another.",
              "USERNAME_TOO_SHORT": "Username is too short",
              "USERNAME_TOO_LONG": "Username is too long",
              "INVALID_USERNAME": "Username is invalid",
              "INVALID_DISPLAY_USERNAME": "Display username is invalid"
            }
          }
        },
        {
          "name": "admin",
          "config": {
            "id": "admin",
            "hooks": {
              "after": [
                {}
              ]
            },
            "endpoints": {},
            "$ERROR_CODES": {
              "FAILED_TO_CREATE_USER": "Failed to create user",
              "USER_ALREADY_EXISTS": "User already exists. Use another email.",
              "YOU_CANNOT_BAN_YOURSELF": "You cannot ban yourself",
              "YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE": "You are not allowed to change users role",
              "YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS": "You are not allowed to create users",
              "YOU_ARE_NOT_ALLOWED_TO_LIST_USERS": "You are not allowed to list users",
              "YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS": "You are not allowed to list users sessions",
              "YOU_ARE_NOT_ALLOWED_TO_BAN_USERS": "You are not allowed to ban users",
              "YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS": "You are not allowed to impersonate users",
              "YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS": "You are not allowed to revoke users sessions",
              "YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS": "You are not allowed to delete users",
              "YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD": "[REDACTED]",
              "BANNED_USER": "You have been banned from this application",
              "YOU_ARE_NOT_ALLOWED_TO_GET_USER": "You are not allowed to get user",
              "NO_DATA_TO_UPDATE": "No data to update",
              "YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS": "You are not allowed to update users",
              "YOU_CANNOT_REMOVE_YOURSELF": "You cannot remove yourself"
            },
            "schema": {
              "user": {
                "fields": {
                  "role": {
                    "type": "string",
                    "required": false,
                    "input": false
                  },
                  "banned": {
                    "type": "boolean",
                    "defaultValue": false,
                    "required": false,
                    "input": false
                  },
                  "banReason": {
                    "type": "string",
                    "required": false,
                    "input": false
                  },
                  "banExpires": {
                    "type": "date",
                    "required": false,
                    "input": false
                  }
                }
              },
              "session": {
                "fields": {
                  "impersonatedBy": {
                    "type": "string",
                    "required": false
                  }
                }
              }
            },
            "options": {
              "defaultRole": "user",
              "ac": {
                "statements": {
                  "series": [
                    "mod",
                    "create",
                    "update",
                    "delete",
                    "merge",
                    "unmerge"
                  ],
                  "apps": [
                    "mod"
                  ],
                  "user": [
                    "create",
                    "list",
                    "set-role",
                    "ban",
                    "impersonate",
                    "delete",
                    "set-password",
                    "get",
                    "update"
                  ],
                  "session": [
                    "list",
                    "revoke",
                    "delete"
                  ]
                }
              },
              "roles": {
                "user": {
                  "statements": {
                    "series": []
                  }
                },
                "moderator": {
                  "statements": {
                    "series": [
                      "mod",
                      "create",
                      "update",
                      "delete",
                      "merge",
                      "unmerge"
                    ]
                  }
                },
                "admin": {
                  "statements": {
                    "series": [
                      "mod",
                      "create",
                      "update",
                      "delete",
                      "merge",
                      "unmerge"
                    ],
                    "apps": [
                      "mod"
                    ],
                    "user": [
                      "create",
                      "list",
                      "set-role",
                      "ban",
                      "impersonate",
                      "delete",
                      "set-password",
                      "get",
                      "update"
                    ],
                    "session": [
                      "list",
                      "revoke",
                      "delete"
                    ]
                  }
                }
              }
            }
          }
        },
        {
          "name": "generic-oauth",
          "config": {
            "id": "generic-oauth",
            "endpoints": {},
            "$ERROR_CODES": {
              "INVALID_OAUTH_CONFIGURATION": "Invalid OAuth configuration"
            }
          }
        },
        {
          "name": "oidc",
          "config": {
            "id": "oidc",
            "hooks": {
              "after": [
                {}
              ]
            },
            "endpoints": {},
            "schema": {
              "oauthApplication": {
                "modelName": "auth_oauth_applications",
                "fields": {
                  "name": {
                    "type": "string"
                  },
                  "icon": {
                    "type": "string",
                    "required": false
                  },
                  "metadata": {
                    "type": "string",
                    "required": false
                  },
                  "clientId": {
                    "type": "string",
                    "unique": true
                  },
                  "clientSecret": {
                    "type": "string",
                    "required": false
                  },
                  "redirectURLs": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "disabled": {
                    "type": "boolean",
                    "required": false,
                    "defaultValue": false
                  },
                  "userId": {
                    "type": "string",
                    "required": false,
                    "references": {
                      "model": "user",
                      "field": "id",
                      "onDelete": "cascade"
                    }
                  },
                  "createdAt": {
                    "type": "date"
                  },
                  "updatedAt": {
                    "type": "date"
                  }
                }
              },
              "oauthAccessToken": {
                "modelName": "auth_oauth_access_tokens",
                "fields": {
                  "accessToken": {
                    "type": "string",
                    "unique": true
                  },
                  "refreshToken": {
                    "type": "string",
                    "unique": true
                  },
                  "accessTokenExpiresAt": {
                    "type": "date"
                  },
                  "refreshTokenExpiresAt": {
                    "type": "date"
                  },
                  "clientId": {
                    "type": "string",
                    "references": {
                      "model": "oauthApplication",
                      "field": "clientId",
                      "onDelete": "cascade"
                    }
                  },
                  "userId": {
                    "type": "string",
                    "required": false,
                    "references": {
                      "model": "user",
                      "field": "id",
                      "onDelete": "cascade"
                    }
                  },
                  "scopes": {
                    "type": "string"
                  },
                  "createdAt": {
                    "type": "date"
                  },
                  "updatedAt": {
                    "type": "date"
                  }
                }
              },
              "oauthConsent": {
                "modelName": "auth_oauth_consents",
                "fields": {
                  "clientId": {
                    "type": "string",
                    "references": {
                      "model": "oauthApplication",
                      "field": "clientId",
                      "onDelete": "cascade"
                    }
                  },
                  "userId": {
                    "type": "string",
                    "references": {
                      "model": "user",
                      "field": "id",
                      "onDelete": "cascade"
                    }
                  },
                  "scopes": {
                    "type": "string"
                  },
                  "createdAt": {
                    "type": "date"
                  },
                  "updatedAt": {
                    "type": "date"
                  },
                  "consentGiven": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        {
          "name": "last-login-method",
          "config": {
            "id": "last-login-method",
            "hooks": {
              "after": [
                {}
              ]
            }
          }
        }
      ],
      "user": {
        "modelName": "auth_users"
      },
      "session": {
        "modelName": "auth_sessions",
        "cookieCache": {
          "enabled": true,
          "maxAge": 300
        }
      },
      "account": {
        "modelName": "auth_accounts",
        "accountLinking": {
          "enabled": true,
          "trustedProviders": [
            "discord",
            "anilist",
            "google",
            "microsoft"
          ],
          "allowDifferentEmails": true
        }
      },
      "verification": {
        "modelName": "auth_verification"
      },
      "rateLimit": {
        "enabled": false
      },
      "database": {
        "_events": {},
        "_eventsCount": 0,
        "options": {
          "host": "192.168.5.116",
          "user": "mangabaka",
          "database": "mangabaka",
          "keepAlive": true,
          "max": 10,
          "min": 0,
          "maxUses": null,
          "allowExitOnIdle": false,
          "maxLifetimeSeconds": 0,
          "idleTimeoutMillis": 10000
        },
        "_clients": [],
        "_idle": [],
        "_expired": {},
        "_pendingQueue": [],
        "ending": false,
        "ended": false
      }
    }
  }
}

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

Backend

Auth config (if applicable)

N/A

Additional context

No response

Originally created by @jippi on GitHub (Sep 23, 2025). Originally assigned to: @himself65 on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Seeing the issue also mentioned in https://github.com/better-auth/better-auth/issues/4757#issuecomment-3322314480 ``` 2025-09-23T03:40:09.339Z ERROR [Better Auth]: [#better-auth]: Couldn't read your auth config. TypeError: z.coerce.boolean(...).meta is not a function at file:///Users/nadilas/workspace/.../node_modules/better-auth/dist/shared/better-auth.CBY7cUGy.mjs:61:44 const getSessionQuerySchema = z.optional( z.object({ /** * If cookie cache is enabled, it will disable the cache * and fetch the session from the database */ >>>> disableCookieCache: z.coerce.boolean().meta({ description: "Disable cookie cache and fetch session from database" }).optional(), disableRefresh: z.coerce.boolean().meta({ description: "Disable session refresh. Useful for checking session status, without updating the session" }).optional() }) ); ``` This happen when using Zod 3 in the root project for me. I'm not ready to move to Zod 4 yet, but would like to keep up to date with better-auth. ### Current vs. Expected behavior See description ### What version of Better Auth are you using? 1.3.10 and later ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.0.0: Mon Aug 25 21:17:51 PDT 2025; root:xnu-12377.1.9~3/RELEASE_ARM64_T6000", "release": "25.0.0", "cpuCount": 8, "cpuModel": "Apple M1 Pro", "totalMemory": "16.00 GB", "freeMemory": "0.12 GB" }, "node": { "version": "v23.11.0", "env": "local" }, "packageManager": { "name": "npm", "version": "10.9.2" }, "frameworks": [ { "name": "svelte", "version": "^5.26.3" }, { "name": "@sveltejs/kit", "version": "^2.20.3" } ], "databases": [ { "name": "pg", "version": "^8.12.0" } ], "betterAuth": { "version": "^1.3.9", "config": { "appName": "MangaBaka.dev", "basePath": "/auth", "disabledPaths": [ "/admin/ban-user", "/admin/impersonate-user", "/admin/list-user-sessions", "/admin/remove-user", "/admin/revoke-user-session", "/admin/revoke-user-sessions", "/admin/set-user-password", "/admin/stop-impersonating", "/admin/unban-user", "/change-email", "/change-password", "/delete-user", "/delete-user/callback", "/forget-password", "/request-password-reset", "/reset-password", "/reset-password/:token", "/send-verification-email", "/sign-in/email", "/sign-in/username", "/sign-up/email", "/verify-email" ], "telemetry": { "enabled": false }, "socialProviders": { "discord": { "enabled": true, "clientId": "[REDACTED]", "clientSecret": "[REDACTED]" }, "google": { "enabled": true, "clientId": "[REDACTED]", "clientSecret": "[REDACTED]" }, "microsoft": { "enabled": true, "clientId": "[REDACTED]", "clientSecret": "[REDACTED]" } }, "baseURL": "http://localhost:5173", "plugins": [ { "name": "open-api", "config": { "id": "open-api", "endpoints": {} } }, { "name": "api-key", "config": { "id": "api-key", "$ERROR_CODES": { "INVALID_METADATA_TYPE": "metadata must be an object or undefined", "REFILL_AMOUNT_AND_INTERVAL_REQUIRED": "refillAmount is required when refillInterval is provided", "REFILL_INTERVAL_AND_AMOUNT_REQUIRED": "refillInterval is required when refillAmount is provided", "USER_BANNED": "User is banned", "UNAUTHORIZED_SESSION": "Unauthorized or invalid session", "KEY_NOT_FOUND": "API Key not found", "KEY_DISABLED": "API Key is disabled", "KEY_EXPIRED": "API Key has expired", "USAGE_EXCEEDED": "API Key has reached its usage limit", "KEY_NOT_RECOVERABLE": "API Key is not recoverable", "EXPIRES_IN_IS_TOO_SMALL": "The expiresIn is smaller than the predefined minimum value.", "EXPIRES_IN_IS_TOO_LARGE": "The expiresIn is larger than the predefined maximum value.", "INVALID_REMAINING": "The remaining count is either too large or too small.", "INVALID_PREFIX_LENGTH": "The prefix length is either too large or too small.", "INVALID_NAME_LENGTH": "The name length is either too large or too small.", "METADATA_DISABLED": "Metadata is disabled.", "RATE_LIMIT_EXCEEDED": "Rate limit exceeded.", "NO_VALUES_TO_UPDATE": "No values to update.", "KEY_DISABLED_EXPIRATION": "Custom key expiration values are disabled.", "INVALID_API_KEY": "Invalid API key.", "INVALID_USER_ID_FROM_API_KEY": "The user id from the API key is invalid.", "INVALID_API_KEY_GETTER_RETURN_TYPE": "API Key getter returned an invalid key type. Expected string.", "SERVER_ONLY_PROPERTY": "The property you're trying to set can only be set from the server auth instance only.", "FAILED_TO_UPDATE_API_KEY": "Failed to update API key", "NAME_REQUIRED": "API Key name is required." }, "hooks": { "before": [ {} ] }, "endpoints": {}, "schema": { "apikey": { "fields": { "name": { "type": "string", "required": false, "input": false }, "start": { "type": "string", "required": false, "input": false }, "prefix": { "type": "string", "required": false, "input": false }, "key": { "type": "string", "required": true, "input": false }, "userId": { "type": "string", "references": { "model": "user", "field": "id" }, "required": true, "input": false }, "refillInterval": { "type": "number", "required": false, "input": false }, "refillAmount": { "type": "number", "required": false, "input": false }, "lastRefillAt": { "type": "date", "required": false, "input": false }, "enabled": { "type": "boolean", "required": false, "input": false, "defaultValue": true }, "rateLimitEnabled": { "type": "boolean", "required": false, "input": false, "defaultValue": true }, "rateLimitTimeWindow": { "type": "number", "required": false, "input": false, "defaultValue": 86400000 }, "rateLimitMax": { "type": "number", "required": false, "input": false, "defaultValue": 10 }, "requestCount": { "type": "number", "required": false, "input": false, "defaultValue": 0 }, "remaining": { "type": "number", "required": false, "input": false }, "lastRequest": { "type": "date", "required": false, "input": false }, "expiresAt": { "type": "date", "required": false, "input": false }, "createdAt": { "type": "date", "required": true, "input": false }, "updatedAt": { "type": "date", "required": true, "input": false }, "permissions": { "type": "string", "required": false, "input": false }, "metadata": { "type": "string", "required": false, "input": true, "transform": {} } }, "modelName": "auth_api_keys" } } } }, { "name": "username", "config": { "id": "username", "endpoints": {}, "schema": { "user": { "fields": { "username": { "type": "string", "required": false, "sortable": true, "unique": true, "returned": true, "transform": {} }, "displayUsername": { "type": "string", "required": false, "transform": {} } } } }, "hooks": { "before": [ {}, {} ] }, "$ERROR_CODES": { "INVALID_USERNAME_OR_PASSWORD": "[REDACTED]", "EMAIL_NOT_VERIFIED": "Email not verified", "UNEXPECTED_ERROR": "Unexpected error", "USERNAME_IS_ALREADY_TAKEN": "Username is already taken. Please try another.", "USERNAME_TOO_SHORT": "Username is too short", "USERNAME_TOO_LONG": "Username is too long", "INVALID_USERNAME": "Username is invalid", "INVALID_DISPLAY_USERNAME": "Display username is invalid" } } }, { "name": "admin", "config": { "id": "admin", "hooks": { "after": [ {} ] }, "endpoints": {}, "$ERROR_CODES": { "FAILED_TO_CREATE_USER": "Failed to create user", "USER_ALREADY_EXISTS": "User already exists. Use another email.", "YOU_CANNOT_BAN_YOURSELF": "You cannot ban yourself", "YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE": "You are not allowed to change users role", "YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS": "You are not allowed to create users", "YOU_ARE_NOT_ALLOWED_TO_LIST_USERS": "You are not allowed to list users", "YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS": "You are not allowed to list users sessions", "YOU_ARE_NOT_ALLOWED_TO_BAN_USERS": "You are not allowed to ban users", "YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS": "You are not allowed to impersonate users", "YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS": "You are not allowed to revoke users sessions", "YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS": "You are not allowed to delete users", "YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD": "[REDACTED]", "BANNED_USER": "You have been banned from this application", "YOU_ARE_NOT_ALLOWED_TO_GET_USER": "You are not allowed to get user", "NO_DATA_TO_UPDATE": "No data to update", "YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS": "You are not allowed to update users", "YOU_CANNOT_REMOVE_YOURSELF": "You cannot remove yourself" }, "schema": { "user": { "fields": { "role": { "type": "string", "required": false, "input": false }, "banned": { "type": "boolean", "defaultValue": false, "required": false, "input": false }, "banReason": { "type": "string", "required": false, "input": false }, "banExpires": { "type": "date", "required": false, "input": false } } }, "session": { "fields": { "impersonatedBy": { "type": "string", "required": false } } } }, "options": { "defaultRole": "user", "ac": { "statements": { "series": [ "mod", "create", "update", "delete", "merge", "unmerge" ], "apps": [ "mod" ], "user": [ "create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "get", "update" ], "session": [ "list", "revoke", "delete" ] } }, "roles": { "user": { "statements": { "series": [] } }, "moderator": { "statements": { "series": [ "mod", "create", "update", "delete", "merge", "unmerge" ] } }, "admin": { "statements": { "series": [ "mod", "create", "update", "delete", "merge", "unmerge" ], "apps": [ "mod" ], "user": [ "create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "get", "update" ], "session": [ "list", "revoke", "delete" ] } } } } } }, { "name": "generic-oauth", "config": { "id": "generic-oauth", "endpoints": {}, "$ERROR_CODES": { "INVALID_OAUTH_CONFIGURATION": "Invalid OAuth configuration" } } }, { "name": "oidc", "config": { "id": "oidc", "hooks": { "after": [ {} ] }, "endpoints": {}, "schema": { "oauthApplication": { "modelName": "auth_oauth_applications", "fields": { "name": { "type": "string" }, "icon": { "type": "string", "required": false }, "metadata": { "type": "string", "required": false }, "clientId": { "type": "string", "unique": true }, "clientSecret": { "type": "string", "required": false }, "redirectURLs": { "type": "string" }, "type": { "type": "string" }, "disabled": { "type": "boolean", "required": false, "defaultValue": false }, "userId": { "type": "string", "required": false, "references": { "model": "user", "field": "id", "onDelete": "cascade" } }, "createdAt": { "type": "date" }, "updatedAt": { "type": "date" } } }, "oauthAccessToken": { "modelName": "auth_oauth_access_tokens", "fields": { "accessToken": { "type": "string", "unique": true }, "refreshToken": { "type": "string", "unique": true }, "accessTokenExpiresAt": { "type": "date" }, "refreshTokenExpiresAt": { "type": "date" }, "clientId": { "type": "string", "references": { "model": "oauthApplication", "field": "clientId", "onDelete": "cascade" } }, "userId": { "type": "string", "required": false, "references": { "model": "user", "field": "id", "onDelete": "cascade" } }, "scopes": { "type": "string" }, "createdAt": { "type": "date" }, "updatedAt": { "type": "date" } } }, "oauthConsent": { "modelName": "auth_oauth_consents", "fields": { "clientId": { "type": "string", "references": { "model": "oauthApplication", "field": "clientId", "onDelete": "cascade" } }, "userId": { "type": "string", "references": { "model": "user", "field": "id", "onDelete": "cascade" } }, "scopes": { "type": "string" }, "createdAt": { "type": "date" }, "updatedAt": { "type": "date" }, "consentGiven": { "type": "boolean" } } } } } }, { "name": "last-login-method", "config": { "id": "last-login-method", "hooks": { "after": [ {} ] } } } ], "user": { "modelName": "auth_users" }, "session": { "modelName": "auth_sessions", "cookieCache": { "enabled": true, "maxAge": 300 } }, "account": { "modelName": "auth_accounts", "accountLinking": { "enabled": true, "trustedProviders": [ "discord", "anilist", "google", "microsoft" ], "allowDifferentEmails": true } }, "verification": { "modelName": "auth_verification" }, "rateLimit": { "enabled": false }, "database": { "_events": {}, "_eventsCount": 0, "options": { "host": "192.168.5.116", "user": "mangabaka", "database": "mangabaka", "keepAlive": true, "max": 10, "min": 0, "maxUses": null, "allowExitOnIdle": false, "maxLifetimeSeconds": 0, "idleTimeoutMillis": 10000 }, "_clients": [], "_idle": [], "_expired": {}, "_pendingQueue": [], "ending": false, "ended": false } } } } ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript N/A ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 09:20:01 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 23, 2025):

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

Better Auth 1.3.10 and later require Zod 4 and are not compatible with Zod 3. The error you’re seeing (z.coerce.boolean(...).meta is not a function) happens because .meta() on coerced types is only available in Zod 4, and Better Auth now uses this feature throughout its codebase. This change was introduced as part of a major migration to Zod v4, and all recent releases and plugins expect Zod 4 APIs (migration PR, dependency update).

There’s no official workaround for using Better Auth 1.3.10+ with Zod 3. If you can’t upgrade your project to Zod 4, you’ll need to downgrade Better Auth to a version before 1.3.10. If you do upgrade, make sure every package in your dependency tree uses Zod 4—having even one package still on Zod 3 will cause this error to persist (issue #4757).

If you want to keep using the latest Better Auth, upgrading all dependencies to Zod 4 is the only reliable solution.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Sep 23, 2025): <!-- Greeting --> Hi @jippi! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> Better Auth 1.3.10 and later require Zod 4 and are not compatible with Zod 3. The error you’re seeing (`z.coerce.boolean(...).meta is not a function`) happens because `.meta()` on coerced types is only available in Zod 4, and Better Auth now uses this feature throughout its codebase. This change was introduced as part of a major migration to Zod v4, and all recent releases and plugins expect Zod 4 APIs ([migration PR](https://github.com/better-auth/better-auth/pull/3399), [dependency update](https://github.com/better-auth/better-auth/pull/4345)). There’s no official workaround for using Better Auth 1.3.10+ with Zod 3. If you can’t upgrade your project to Zod 4, you’ll need to downgrade Better Auth to a version before 1.3.10. If you do upgrade, make sure every package in your dependency tree uses Zod 4—having even one package still on Zod 3 will cause this error to persist ([issue #4757](https://github.com/better-auth/better-auth/issues/4757)). If you want to keep using the latest Better Auth, upgrading all dependencies to Zod 4 is the only reliable solution. <!-- 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/8fb59c03-8ba0-4b79-812f-8b2af3281fb6?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/8fb59c03-8ba0-4b79-812f-8b2af3281fb6?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/8fb59c03-8ba0-4b79-812f-8b2af3281fb6?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/8fb59c03-8ba0-4b79-812f-8b2af3281fb6?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/8fb59c03-8ba0-4b79-812f-8b2af3281fb6?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/8fb59c03-8ba0-4b79-812f-8b2af3281fb6?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/8fb59c03-8ba0-4b79-812f-8b2af3281fb6?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&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/4837)
Author
Owner

@jippi commented on GitHub (Sep 23, 2025):

Full build output from vite build

node:internal/event_target:1101
  process.nextTick(() => { throw err; });
                           ^
TypeError [Error]: z.coerce.boolean(...).meta is not a function
    at file:///Users/jippi/src/jippi/mangabaka-catalog/.svelte-kit/output/server/chunks/auth2.js:970:44
    at ModuleJob.run (node:internal/modules/esm/module_job:274:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:644:26)
    at async get_page_options (file:///Users/jippi/src/jippi/mangabaka-catalog/node_modules/@sveltejs/kit/src/exports/vite/static_analysis/index.js:224:19)
    at async build_server_nodes (file:///Users/jippi/src/jippi/mangabaka-catalog/node_modules/@sveltejs/kit/src/exports/vite/build/build_server.js:98:25)
    at async analyse (file:///Users/jippi/src/jippi/mangabaka-catalog/node_modules/@sveltejs/kit/src/core/postbuild/analyse.js:72:2)
    at async MessagePort.<anonymous> (file:///Users/jippi/src/jippi/mangabaka-catalog/node_modules/@sveltejs/kit/src/utils/fork.js:23:16)

Node.js v23.11.0
@jippi commented on GitHub (Sep 23, 2025): Full build output from `vite build` ``` node:internal/event_target:1101 process.nextTick(() => { throw err; }); ^ TypeError [Error]: z.coerce.boolean(...).meta is not a function at file:///Users/jippi/src/jippi/mangabaka-catalog/.svelte-kit/output/server/chunks/auth2.js:970:44 at ModuleJob.run (node:internal/modules/esm/module_job:274:25) at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:644:26) at async get_page_options (file:///Users/jippi/src/jippi/mangabaka-catalog/node_modules/@sveltejs/kit/src/exports/vite/static_analysis/index.js:224:19) at async build_server_nodes (file:///Users/jippi/src/jippi/mangabaka-catalog/node_modules/@sveltejs/kit/src/exports/vite/build/build_server.js:98:25) at async analyse (file:///Users/jippi/src/jippi/mangabaka-catalog/node_modules/@sveltejs/kit/src/core/postbuild/analyse.js:72:2) at async MessagePort.<anonymous> (file:///Users/jippi/src/jippi/mangabaka-catalog/node_modules/@sveltejs/kit/src/utils/fork.js:23:16) Node.js v23.11.0 ```
Author
Owner

@dosubot[bot] commented on GitHub (Sep 23, 2025):

The build error is caused by Better Auth 1.3.10+ using Zod 4-only features like .meta() on coerced types, which aren't available in Zod 3. This is a hard incompatibility—Vite build fails because Better Auth expects Zod 4 APIs throughout its codebase and plugins. Vite config changes (like optimizeDeps.exclude) won't fix this, as the root issue is the Zod version mismatch.

To resolve this, you need to either upgrade all dependencies to Zod 4 or downgrade Better Auth to a version before 1.3.10. There is no workaround for using Better Auth 1.3.10+ with Zod 3—mixed Zod versions in your dependency tree will continue to cause this error. More details are in issue #4757.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Sep 23, 2025): <!-- Answer --> The build error is caused by Better Auth 1.3.10+ using Zod 4-only features like `.meta()` on coerced types, which aren't available in Zod 3. This is a hard incompatibility—Vite build fails because Better Auth expects Zod 4 APIs throughout its codebase and plugins. Vite config changes (like `optimizeDeps.exclude`) won't fix this, as the root issue is the Zod version mismatch. To resolve this, you need to either upgrade all dependencies to Zod 4 or downgrade Better Auth to a version before 1.3.10. There is no workaround for using Better Auth 1.3.10+ with Zod 3—mixed Zod versions in your dependency tree will continue to cause this error. More details are in [issue #4757](https://github.com/better-auth/better-auth/issues/4757). <!-- 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/9dcc494f-0785-499e-a518-ee0b5e82d6ef?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/9dcc494f-0785-499e-a518-ee0b5e82d6ef?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/9dcc494f-0785-499e-a518-ee0b5e82d6ef?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/9dcc494f-0785-499e-a518-ee0b5e82d6ef?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/9dcc494f-0785-499e-a518-ee0b5e82d6ef?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/9dcc494f-0785-499e-a518-ee0b5e82d6ef?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/9dcc494f-0785-499e-a518-ee0b5e82d6ef?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&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/4837)
Author
Owner

@jippi commented on GitHub (Sep 23, 2025):

Might be a regression from #4593 that removed explicit version import, and thus broke v3 usage

@jippi commented on GitHub (Sep 23, 2025): Might be a regression from #4593 that removed explicit version import, and thus broke v3 usage
Author
Owner

@himself65 commented on GitHub (Sep 23, 2025):

what's your zod version?

@himself65 commented on GitHub (Sep 23, 2025): what's your zod version?
Author
Owner

@jippi commented on GitHub (Sep 23, 2025):

@himself65 I'm using Zod 3.25.76 (https://github.com/colinhacks/zod/releases/tag/v3.25.76) the last release in Zod 3.x I believe

@jippi commented on GitHub (Sep 23, 2025): @himself65 I'm using Zod `3.25.76` (https://github.com/colinhacks/zod/releases/tag/v3.25.76) the last release in Zod 3.x I believe
Author
Owner

@himself65 commented on GitHub (Sep 23, 2025):

Thanks for feedback, im fixing right now

@himself65 commented on GitHub (Sep 23, 2025): Thanks for feedback, im fixing right now
Author
Owner

@jippi commented on GitHub (Sep 23, 2025):

dude, that was so fast - thank you !

@jippi commented on GitHub (Sep 23, 2025): dude, that was _so_ fast - thank you !
Author
Owner

@jippi commented on GitHub (Sep 23, 2025):

@himself65 there also seem to be TypeError [Error]: z.email is not a function in my build errors now

would be z.string().email() in v3

@jippi commented on GitHub (Sep 23, 2025): @himself65 there also seem to be `TypeError [Error]: z.email is not a function` in my build errors now would be `z.string().email()` in v3
Author
Owner

@jippi commented on GitHub (Sep 23, 2025):

Fixing those locally, my build then fail with z.record(...).meta is not a function

@jippi commented on GitHub (Sep 23, 2025): Fixing those locally, my build then fail with `z.record(...).meta is not a function`
Author
Owner

@jippi commented on GitHub (Sep 23, 2025):

From the dist this is the files

$ grep -ri 'z.email' .
./shared/better-auth.D-4EtUes.mjs:      email: z.email().describe("The email to send the verification email to"),
./shared/better-auth.D-4EtUes.mjs:      email: z.email().describe(
./shared/better-auth.D-4EtUes.mjs:      newEmail: z.email().describe("The new email address to set must be a valid email address"),
./api/index.mjs:    const isValidEmail = z.email().safeParse(email);

and these

$ grep -ri 'z.record' | grep '.meta('
./shared/better-auth.Df_5rmaV.mjs:            jwks: z.record(z.any(), z.any()).meta({
./shared/better-auth.Df_5rmaV.mjs:            metadata: z.record(z.any(), z.any()).meta({

and with those, my app compiles :)

@jippi commented on GitHub (Sep 23, 2025): From the dist this is the files ``` $ grep -ri 'z.email' . ./shared/better-auth.D-4EtUes.mjs: email: z.email().describe("The email to send the verification email to"), ./shared/better-auth.D-4EtUes.mjs: email: z.email().describe( ./shared/better-auth.D-4EtUes.mjs: newEmail: z.email().describe("The new email address to set must be a valid email address"), ./api/index.mjs: const isValidEmail = z.email().safeParse(email); ``` and these ``` $ grep -ri 'z.record' | grep '.meta(' ./shared/better-auth.Df_5rmaV.mjs: jwks: z.record(z.any(), z.any()).meta({ ./shared/better-auth.Df_5rmaV.mjs: metadata: z.record(z.any(), z.any()).meta({ ``` and with those, my app compiles :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2000