[PR #6540] [MERGED] fix(openapi): mark /get-session response as nullable #6732

Closed
opened 2026-03-13 13:09:45 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6540
Author: @GautamBytes
Created: 12/5/2025
Status: Merged
Merged: 12/5/2025
Merged by: @Bekacru

Base: canaryHead: fix/get-session-nullable


📝 Commits (2)

  • b000105 fix(openapi): mark get-session response as nullable
  • 210f2d6 chore: trigger ci

📊 Changes

1 file changed (+1 additions, -0 deletions)

View changed files

📝 packages/better-auth/src/api/routes/session.ts (+1 -0)

📄 Description

Fixes

Fixes #6537

Description

The /get-session endpoint returns null when no session exists (or is invalid/expired), but the current OpenAPI schema defines the 200 response strictly as an object with required session and user fields.

This discrepancy causes issues for developers using client generators (like openapi-typescript-codegen or Orval), as the generated types do not account for the possibility of a null response, leading to potential runtime errors or type validation failures.

Changes

  • Updated packages/better-auth/src/api/routes/session.ts to add nullable: true to the response schema of getSession.

Summary by cubic

Marks the /get-session 200 response as nullable in the OpenAPI schema to match real behavior when no session exists. This fixes mismatched generated types and avoids runtime/type errors in clients (e.g., openapi-typescript-codegen, Orval).

Written for commit 210f2d69d1. Summary will update automatically on new commits.


🔄 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/6540 **Author:** [@GautamBytes](https://github.com/GautamBytes) **Created:** 12/5/2025 **Status:** ✅ Merged **Merged:** 12/5/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/get-session-nullable` --- ### 📝 Commits (2) - [`b000105`](https://github.com/better-auth/better-auth/commit/b0001053ba8d6e87311fbe282fa98ab9b64c8ae3) fix(openapi): mark get-session response as nullable - [`210f2d6`](https://github.com/better-auth/better-auth/commit/210f2d69d1f78d52f326f27dab9642a1a88d13a3) chore: trigger ci ### 📊 Changes **1 file changed** (+1 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/session.ts` (+1 -0) </details> ### 📄 Description ## Fixes Fixes #6537 ## Description The `/get-session` endpoint returns `null` when no session exists (or is invalid/expired), but the current OpenAPI schema defines the 200 response strictly as an object with required `session` and `user` fields. This discrepancy causes issues for developers using client generators (like `openapi-typescript-codegen` or `Orval`), as the generated types do not account for the possibility of a `null` response, leading to potential runtime errors or type validation failures. ## Changes - Updated `packages/better-auth/src/api/routes/session.ts` to add `nullable: true` to the response schema of `getSession`. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Marks the /get-session 200 response as nullable in the OpenAPI schema to match real behavior when no session exists. This fixes mismatched generated types and avoids runtime/type errors in clients (e.g., openapi-typescript-codegen, Orval). <sup>Written for commit 210f2d69d1f78d52f326f27dab9642a1a88d13a3. Summary will update automatically on new commits.</sup> <!-- 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-03-13 13:09:45 -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#6732