Skip to content

opencode attach ignores OPENCODE_SERVER_USERNAME, hardcodes "opencode" #18611

Closed as not planned

Description

@ChrisOboe

Description

opencode attach constructs the Basic auth header by hardcoding the username as "opencode", regardless of the OPENCODE_SERVER_USERNAME environment variable.

In packages/opencode/src/cli/cmd/tui/attach.ts, the auth header is built as:

const auth = Basic ${Buffer.from(opencode:${password}`).toString("base64")}

By contrast, packages/opencode/src/cli/cmd/run.ts correctly reads the env var:

const username = process.env.OPENCODE_SERVER_USERNAME ?? "opencode"

This means opencode attach always authenticates as opencode even when the server requires a different username (e.g. when OPENCODE_SERVER_USERNAME is set). Authentication fails silently or produces an unhelpful error.

Plugins

No response

OpenCode version

1.2.27

Steps to reproduce

Run opencode serve (or connect to a remote server) with a non-default username configured via OPENCODE_SERVER_PASSWORD/OPENCODE_SERVER_USERNAME.
Set OPENCODE_SERVER_USERNAME=myuser and OPENCODE_SERVER_PASSWORD=mypassword in the client environment.
Run opencode attach.
Authentication fails — the wrong username (opencode) is sent instead of myuser.

Screenshot and/or share link

No response

Operating System

NixOS (x86_64-linux)

Terminal

wezterm

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 22, 2026
  2. added a commit that references this issue on Mar 22, 2026
    bf27393
  3. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions