[PR #5321] [CLOSED] fix: Add default values to ogSchema to prevent ZodError during build #14172

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5321
Author: @ibxbit
Created: 10/15/2025
Status: Closed

Base: canaryHead: fix-og-schema-defaults


📝 Commits (9)

  • f0e78d0 docs: Fix typo in localohst to localhost in .env.example
  • 4266833 Merge branch 'canary' into canary
  • ae70505 Merge branch 'canary' of https://github.com/better-auth/better-auth into canary
  • 442c689 Merge branch 'better-auth:canary' into canary
  • 7751722 fix: add default values to ogSchema to prevent ZodError during prerendering
  • e15267e style: apply biome formatting fixes
  • 52cbd71 Merge branch 'canary' into fix-og-schema-defaults
  • 584d6d7 Merge branch 'canary' into fix-og-schema-defaults
  • e608f99 fix: resolve CI localStorage error and implement z.enum for ogSchema

📊 Changes

3 files changed (+32 additions, -4 deletions)

View changed files

📝 docs/app/api/og/route.tsx (+3 -3)
packages/better-auth/vitest-setup.ts (+26 -0)
📝 packages/better-auth/vitest.config.ts (+3 -1)

📄 Description

Problem:

The original ogSchema in docs/app/api/og/route.tsx required heading, mode, and type as mandatory string query parameters, causing a ZodError during prerendering when these params were undefined (e.g., for /docs/authentication/spotify). This led to a TypeError: Invalid URL with input: 'undefined/api/og', breaking the Next.js build process.

Solution:

Updated ogSchema to include default values: heading: z.string().default("Better Auth Documentation"), mode: z.string().default("dark"), and type: z.string().default("documentation"). This ensures the route handles missing query params gracefully, resolving the build error by providing fallback values, with type adjusted to lowercase "documentation" for consistency with expected usage.


Summary by cubic

Add defaults to the docs OG image schema so missing query params no longer crash prerendering. This fixes the Next.js build error (ZodError/Invalid URL) on pages without heading, mode, or type.

  • Bug Fixes
    • Set defaults: heading "Better Auth Documentation", mode "dark", type "documentation".
    • Handles undefined params during prerender and restores successful docs build (e.g., /docs/authentication/spotify).

🔄 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/5321 **Author:** [@ibxbit](https://github.com/ibxbit) **Created:** 10/15/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix-og-schema-defaults` --- ### 📝 Commits (9) - [`f0e78d0`](https://github.com/better-auth/better-auth/commit/f0e78d08d95b96cd89be40b750298ecef58dbaab) docs: Fix typo in localohst to localhost in .env.example - [`4266833`](https://github.com/better-auth/better-auth/commit/426683390811ae3f47b5235b483e5ae9b3dbb19e) Merge branch 'canary' into canary - [`ae70505`](https://github.com/better-auth/better-auth/commit/ae705058f9ac305d8673d6302b19dcc0b874c125) Merge branch 'canary' of https://github.com/better-auth/better-auth into canary - [`442c689`](https://github.com/better-auth/better-auth/commit/442c68935e18a611d691948cbd0b2b604f8225d9) Merge branch 'better-auth:canary' into canary - [`7751722`](https://github.com/better-auth/better-auth/commit/7751722ff1cd5eefe55a5e3d2e1da1d87dfa9d2c) fix: add default values to ogSchema to prevent ZodError during prerendering - [`e15267e`](https://github.com/better-auth/better-auth/commit/e15267e33c7f420441f75fde939f3cb1546dc21e) style: apply biome formatting fixes - [`52cbd71`](https://github.com/better-auth/better-auth/commit/52cbd717b893ee35a32f966779ee9de66a42a6f3) Merge branch 'canary' into fix-og-schema-defaults - [`584d6d7`](https://github.com/better-auth/better-auth/commit/584d6d7d7a3b5c9195b84261e3934415b0d3c1e8) Merge branch 'canary' into fix-og-schema-defaults - [`e608f99`](https://github.com/better-auth/better-auth/commit/e608f99df1caff836f32c521068dda0c0216173b) fix: resolve CI localStorage error and implement z.enum for ogSchema ### 📊 Changes **3 files changed** (+32 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `docs/app/api/og/route.tsx` (+3 -3) ➕ `packages/better-auth/vitest-setup.ts` (+26 -0) 📝 `packages/better-auth/vitest.config.ts` (+3 -1) </details> ### 📄 Description **Problem:** The original ogSchema in docs/app/api/og/route.tsx required heading, mode, and type as mandatory string query parameters, causing a ZodError during prerendering when these params were undefined (e.g., for /docs/authentication/spotify). This led to a TypeError: Invalid URL with input: 'undefined/api/og', breaking the Next.js build process. **Solution:** Updated ogSchema to include default values: heading: z.string().default("Better Auth Documentation"), mode: z.string().default("dark"), and type: z.string().default("documentation"). This ensures the route handles missing query params gracefully, resolving the build error by providing fallback values, with type adjusted to lowercase "documentation" for consistency with expected usage. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add defaults to the docs OG image schema so missing query params no longer crash prerendering. This fixes the Next.js build error (ZodError/Invalid URL) on pages without heading, mode, or type. - **Bug Fixes** - Set defaults: heading "Better Auth Documentation", mode "dark", type "documentation". - Handles undefined params during prerender and restores successful docs build (e.g., /docs/authentication/spotify). <!-- 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-04-13 09:20:47 -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#14172