Skip to content

Fix: opencode run --attach should pass auth headers from env vars#16119

Closed
hobostay wants to merge 1 commit intoanomalyco:devfrom
hobostay:fix/run-attach-auth-headers-issue-16096
Closed

Fix: opencode run --attach should pass auth headers from env vars#16119
hobostay wants to merge 1 commit intoanomalyco:devfrom
hobostay:fix/run-attach-auth-headers-issue-16096

Conversation

@hobostay
Copy link
Contributor

@hobostay hobostay commented Mar 5, 2026

Fixes #16096

Description

When using opencode run --attach=localhost:<port> with
OPENCODE_SERVER_USERNAME and OPENCODE_SERVER_PASSWORD env vars,
the command failed with "Error: Session not found".

The run command did not pass auth headers to createOpencodeClient,
while the attach TUI command correctly builds Basic auth headers from env vars.

Changes

Modified packages/opencode/src/cli/cmd/run.ts to:

  • Read OPENCODE_SERVER_PASSWORD and OPENCODE_SERVER_USERNAME env vars
  • Create Basic auth headers when password is provided
  • Pass headers to createOpencodeClient

This matches the behavior of the attach TUI command in
packages/opencode/src/cli/cmd/tui/attach.ts.

Fixes anomalyco#16096

When using `opencode run --attach=localhost:<port>` with
OPENCODE_SERVER_USERNAME and OPENCODE_SERVER_PASSWORD env vars,
the command failed with "Error: Session not found".

This commit adds auth header support to the `run` command's `--attach`
mode, matching the behavior of the `attach` TUI command.

Changes:
- Read OPENCODE_SERVER_PASSWORD and OPENCODE_SERVER_USERNAME env vars
- Create Basic auth headers when password is provided
- Pass headers to createOpencodeClient
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Hey! Your PR title Fix: opencode run --attach should pass auth headers from env vars doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

The following comment was made by an LLM, it may be inaccurate:

Potential duplicate found:

This appears to be addressing the exact same issue as PR #16119. Both are fixing the opencode run --attach command to pass auth headers. The titles and scope are nearly identical, suggesting one may be a duplicate of the other.

@hobostay
Copy link
Contributor Author

hobostay commented Mar 5, 2026

Closing as duplicate of #16097 which already fixes this issue with the correct title format.

@hobostay hobostay closed this Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor needs:compliance This means the issue will auto-close after 2 hours. needs:title

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opencode run --attach ignores OPENCODE_SERVER_PASSWORD

1 participant