Skip to content

Conversation

@monadoid
Copy link
Contributor

@monadoid monadoid commented Jan 6, 2026

why

Generated sdks need to send empty object for /end endpoint to match prod api

what changed

Added dummy optional param to schema to force proper code gen

test plan

Confirmed that the generated wheel linked below by stainless is correct.


Summary by cubic

Added an optional _forceBody field to SessionEndRequest so Stainless generates a body parameter for the endpoint. The server still accepts {} and clients can omit the field, fixing missing-body issues on session end requests.

Written for commit 7f8a7bc. Summary will update on new commits.

@changeset-bot
Copy link

changeset-bot bot commented Jan 6, 2026

⚠️ No Changeset found

Latest commit: 7f8a7bc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

✱ Stainless preview builds

This PR will update the stagehand SDKs with the following commit message.

feat: Added optional param to force empty object
⚠️ stagehand-csharp studio · conflict

There was a regression in your SDK.

stagehand-php studio · code

Your SDK built successfully.
generate ✅lint ✅test ✅

⚠️ stagehand-ruby studio · conflict

There was a regression in your SDK.

⚠️ stagehand-python studio · code

There was a regression in your SDK.
generate ✅build ✅lint ❗test ✅

pip install https://pkg.stainless.com/s/stagehand-python/b15e0976bc356e0ce09b331705ccd2b8805e1bfa/stagehand_alpha-0.1.0-py3-none-any.whl
⚠️ stagehand-kotlin studio · code

There was a regression in your SDK.
generate ⚠️lint ✅test ✅

⚠️ stagehand-typescript studio · code

There was a regression in your SDK.
generate ✅build ✅lint ✅test ❗

npm install https://pkg.stainless.com/s/stagehand-typescript/c5c359889755d7e65696b316ac3ea8eb08f84cf1/dist.tar.gz
⚠️ stagehand-java studio · code

There was a regression in your SDK.
generate ⚠️lint ❗test ✅

stagehand-go studio · code

Your SDK built successfully.
generate ✅lint ✅test ✅

go get github.com/stainless-sdks/stagehand-go@f4b3511ce275895ef9bce6fc9348813e6b860321
stagehand-cli studio · code

Your SDK built successfully.
generate ✅lint ✅test ⏳


This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
Last updated: 2026-01-06 19:43:59 UTC

@monadoid monadoid marked this pull request as ready for review January 6, 2026 19:20
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 6, 2026

Greptile Summary

Added optional _forceBody parameter to SessionEndRequest to ensure Stainless SDK generator creates a body parameter for the /end endpoint

  • The TypeScript schema uses z.undefined().optional() which allows the field to be omitted but cannot be set to any value
  • The OpenAPI spec uses not: {} constraint which means the field can never be valid (clever workaround since {} matches anything, so not: {} matches nothing)
  • This ensures generated SDK clients will send an empty JSON object {} but cannot actually set the _forceBody field
  • Server validation still accepts {} as expected, and existing tests continue to pass
  • This completes the fix from PR /end endpoint returns empty object #1500 by ensuring Stainless generates proper client code

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The changes are minimal, well-documented, and use established workarounds for SDK generation. Both implementations (TypeScript and OpenAPI) are aligned and ensure backward compatibility while fixing the Stainless SDK generation issue. The approach is clever and maintains the contract that the server accepts empty objects.
  • No files require special attention

Important Files Changed

Filename Overview
packages/core/lib/v3/types/public/api.ts Added _forceBody: z.undefined().optional() to SessionEndRequestSchema to ensure Stainless generates body parameter while keeping server accepting empty object
packages/server/openapi.v3.yaml Added _forceBody property with not: {} constraint to SessionEndRequest schema, ensuring property cannot be set but forces body parameter generation

Sequence Diagram

sequenceDiagram
    participant Client as SDK Client
    participant Stainless as Stainless Generator
    participant OpenAPI as OpenAPI Spec
    participant Zod as Zod Schema
    participant Server as Fastify Server

    Note over OpenAPI,Zod: Before: properties: {}
    Note over Client: Problem: Empty object doesn't<br/>force body parameter

    Note over OpenAPI,Zod: After: properties with _forceBody
    
    Stainless->>OpenAPI: Read SessionEndRequest schema
    OpenAPI-->>Stainless: _forceBody with not: {} constraint
    Note over Stainless: Detects property exists,<br/>generates body parameter
    Stainless->>Client: Generate SDK with body param

    Client->>Server: POST /v1/sessions/{id}/end<br/>Content-Type: application/json<br/>Body: {}
    Server->>Zod: Validate request body
    Note over Zod: _forceBody: z.undefined().optional()<br/>Accepts {} (field omitted)
    Zod-->>Server: Validation passes
    Server-->>Client: 200 OK { success: true }
Loading

@monadoid monadoid merged commit 62f2869 into main Jan 6, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants