Skip to content

fix(core): respect explicit session ids in session create#21571

Open
sjawhar wants to merge 1 commit intoanomalyco:devfrom
sjawhar:fix/session-create-duplicate-id
Open

fix(core): respect explicit session ids in session create#21571
sjawhar wants to merge 1 commit intoanomalyco:devfrom
sjawhar:fix/session-create-duplicate-id

Conversation

@sjawhar
Copy link
Copy Markdown

@sjawhar sjawhar commented Apr 8, 2026

Issue for this PR

Closes #21568

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This makes POST /session respect an explicit id when one is provided.

Before this change, the server-side session creation path ignored id, so creating the same explicit session twice returned 200 twice and the existing DuplicateIDError / 409 path was unreachable.

This PR wires id through Session.create, maps duplicate session insertions to DuplicateIDError, updates the route error schema to include 409, and updates the generated SDK/types to match the actual API.

How did you verify your code works?

  • cd packages/opencode && bun test test/server/session-messages.test.ts
  • cd packages/opencode && bun typecheck
  • cd packages/sdk/js && bun typecheck
  • Built-binary smoke test against opencode serve:
    • first POST /session with explicit id returned 200
    • second identical create returned 409 with DuplicateIDError

Screenshots / recordings

N/A (API-only change)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@sjawhar sjawhar force-pushed the fix/session-create-duplicate-id branch 3 times, most recently from c5d0d3e to 9db316e Compare April 11, 2026 17:38
@sjawhar sjawhar requested a review from adamdotdevin as a code owner April 11, 2026 17:38
@sjawhar sjawhar force-pushed the fix/session-create-duplicate-id branch from 07489a3 to e71f234 Compare April 16, 2026 03:42
@sjawhar sjawhar force-pushed the fix/session-create-duplicate-id branch from e71f234 to a88683b Compare April 16, 2026 22:42
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.

POST /session ignores explicit id so duplicate-id handling is unreachable

1 participant