[PR #13221] fix(run): prevent session-not-found when server auth env vars are set #14563

Open
opened 2026-02-16 18:19:20 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13221

State: open
Merged: No


Fixes #8502

Summary

  • add createInternalFetch helper for run-mode internal SDK calls
  • inject local Basic Auth header when OPENCODE_SERVER_PASSWORD is set
  • keep explicit Authorization headers untouched
  • add regression tests covering authenticated internal fetch behavior

Why

opencode run uses an internal in-process server client. When server auth env vars are set, the server expects Basic Auth, but run-mode requests previously sent none, which could break session creation and surface as "Session not found".

Validation

  • cd packages/opencode && bun test test/cli/run-auth.test.ts (3 passing tests)
  • Repro on dev with env vars set: fails with Error: Session not found
  • Same repro on this branch: succeeds and returns model output
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13221 **State:** open **Merged:** No --- Fixes #8502 ## Summary - add `createInternalFetch` helper for run-mode internal SDK calls - inject local Basic Auth header when `OPENCODE_SERVER_PASSWORD` is set - keep explicit `Authorization` headers untouched - add regression tests covering authenticated internal fetch behavior ## Why `opencode run` uses an internal in-process server client. When server auth env vars are set, the server expects Basic Auth, but run-mode requests previously sent none, which could break session creation and surface as "Session not found". ## Validation - `cd packages/opencode && bun test test/cli/run-auth.test.ts` (3 passing tests) - Repro on `dev` with env vars set: fails with `Error: Session not found` - Same repro on this branch: succeeds and returns model output
yindo added the pull-request label 2026-02-16 18:19:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14563