Skip to content

Conversation

@monadoid
Copy link
Contributor

@monadoid monadoid commented Jan 5, 2026

why

Right now our server /end endpoint doesn’t match the production Stagehand API contract: prod expects a non-empty JSON body when Content-Type: application/json is set, so a call to /end that sends an empty body fails. This change makes our server + OpenAPI spec match prod so downstream generated SDKs send an empty object.

what changed

Defined a strict empty-object request schema for /end (SessionEndRequest) and made it a required request body in the route + emitted OpenAPI. Updated the /end handler response to match prod ({ "success": true }) and added a server test covering the body requirement.

  • Also added a stainless.yaml

test plan

Regenerate the Python SDK and verify sessions.end() succeeds against production

@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2026

⚠️ No Changeset found

Latest commit: 92a1e55

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 5, 2026

✱ Stainless preview builds

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

feat: /end endpoint returns 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 · code

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

⚠️ stagehand-python studio · code

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

pip install https://pkg.stainless.com/s/stagehand-python/68a57c7d0270c8d27553479abdb59c40ba473bfe/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/beabba6764d17b394b75507ea0b7c84d9c870b6e/dist.tar.gz
stagehand-go studio · code

Your SDK built successfully.
generate ✅lint ✅test ✅

go get github.com/stainless-sdks/stagehand-go@af4b8a5d5025f4bad9e93d02f854c00b80380e46
⚠️ stagehand-java studio · code

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

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 03:55:53 UTC

@monadoid monadoid changed the title /end endpoint returns empty object, /v1 normalization /end endpoint returns empty object Jan 6, 2026
@monadoid monadoid marked this pull request as ready for review January 6, 2026 02:11
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.

1 issue found across 7 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/server/test/end.test.ts">

<violation number="1" location="packages/server/test/end.test.ts:33">
P2: Resource leak: `afterAll` should be `afterEach` to match the `beforeEach` that creates a new app for each test. Currently, only the last app instance is closed.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 6, 2026

Greptile Summary

This PR aligns the /end endpoint with production Stagehand API contract by requiring a strict empty JSON object request body and updating the response format. The changes span the API type definitions, route handler, OpenAPI spec generation, and test coverage. A new stainless.yml configuration file enables production-ready SDK generation across multiple languages.

Key Changes:

  • Added SessionEndRequestSchema enforcing empty object validation with .strict() to reject extra properties
  • Updated route handler to return { success: true } directly instead of wrapping empty data
  • Added comprehensive test coverage validating body requirements (empty body rejection, extra keys rejection, success case)
  • Updated OpenAPI specification with requestBody declaration and SessionEndRequest schema
  • Added stainless.yml configuration for multi-language SDK generation (Python, Go, Java, TypeScript, Ruby, PHP, CLI, C#)
  • Updated GitHub workflows to use the new Stainless configuration file

Confidence Score: 5/5

  • This PR is safe to merge with no identified issues. All changes are well-structured, properly tested, and maintain API contract compliance.
  • Score reflects comprehensive implementation: strict schema validation prevents malformed requests, route handler correctly implements the new contract, test suite thoroughly covers edge cases (empty payload, extra keys, success path), OpenAPI spec is updated consistently, and SDK generation configuration is properly configured. No breaking changes for clients sending valid empty objects, and production API alignment ensures downstream SDK compatibility.
  • No files require special attention

Important Files Changed

Filename Overview
packages/core/lib/v3/types/public/api.ts Added SessionEndRequestSchema - a strict, empty object schema that enforces the production API contract. The schema follows the existing naming convention and is properly placed in the Session End section. Type inference is handled correctly.
packages/server/src/routes/v1/sessions/_id/end.ts Route handler correctly updated to enforce empty object request body via SessionEndRequestSchema and returns { success: true } instead of wrapping empty data. Response now matches production contract. Import cleanup of unused success function is correct.
packages/server/test/end.test.ts New comprehensive test suite covers the body requirement: validates 400 on empty string payload with JSON content-type, 400 on extra keys, and 200 on valid empty object. Tests are well-structured with proper mocking and assertions.
packages/server/openapi.v3.yaml OpenAPI spec updated with SessionEndRequest schema and requestBody declaration. The schema correctly defines empty object with additionalProperties: false. Body is marked as required, matching route validation.
stainless.yml New Stainless configuration file with comprehensive SDK generation settings. Defines targets (Python, Go, Java, TypeScript, etc.), authentication schemes, resource organization, and client settings. Enables production-ready SDK generation across multiple languages.

Sequence Diagram

sequenceDiagram
    participant Client as Client SDK
    participant Server as /end Endpoint
    participant Store as Session Store
    
    Client->>Server: POST /sessions/{id}/end<br/>Body: {}
    activate Server
    
    Server->>Server: Validate body against<br/>SessionEndRequestSchema
    
    alt Invalid Body (empty string or extra keys)
        Server-->>Client: 400 Bad Request
    else Valid Body ({})
        Server->>Store: endSession(sessionId)
        activate Store
        Store-->>Server: Session terminated
        deactivate Store
        
        Server-->>Client: 200 OK<br/>{ success: true }
    end
    
    deactivate Server
Loading

@monadoid monadoid merged commit 723a7fd into main Jan 6, 2026
19 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