Skip to content

cli: TUI fails to connect to password-protected explicit server via --server #49427

Closed

Description

@sergio-asenjo

Summary

opencode --server <url> against a password-protected opencode serve always fails the startup health check with UnsupportedContentType, in all credential forms. The same URL works with opencode run and opencode api, so the server side is fine — only the TUI startup path fails.

Environment

  • opencode version: 2.0.5
  • OS: Linux 7.2.6-arch2-1 (linux x64)
  • Terminal: Unavailable: terminal environment variables are not set
  • Shell: /usr/bin/bash
  • Install/channel: latest
  • Active plugins: Omitted at reporter's request

Reproduction

  1. Start a password-protected server: opencode serve --hostname 0.0.0.0 --port 4096 with OPENCODE_SERVER_PASSWORD set.
  2. Run opencode --server http://127.0.0.1:4096 — fails.
  3. Retry with credentials in URL (http://opencode:<pass>@127.0.0.1:4096) and as ?auth_token=<base64(user:pass)> — both fail identically.
  4. Run opencode run --server "<auth_token form>" "hi" — succeeds. opencode api --server "<userinfo form>" get /api/status — succeeds.

Expected Behavior

The TUI connects to the explicit server the same way run and api do.

Actual Behavior

Error: Server at http://127.0.0.1:4096 did not provide a compatible V2 health response ... [cause]: ClientError: UnsupportedContentType

Unauthenticated /api/status returns 401 with an empty body, so the TUI check appears to send no credentials in any URL form.

Additional Context

  • The cli.json schema has no default-server field, so --server cannot be defaulted; aliases/functions are the only workaround, and they hit this bug.
  • No doc describes TUI --server authentication (CLI, Web, Commands, and client guides checked).

Activity

  1. github-actions commented on Sep 17, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    • v2 serve: configured Basic Auth credentials always return 401 #45856: v2 serve: configured Basic Auth credentials always return 401 — also covers authentication failures against a password-protected opencode serve endpoint, though that issue focuses on Basic Auth always rejecting valid credentials while this one specifically identifies that the TUI --server startup path sends no credentials at all.

    If these are the same root cause, it may make sense to consolidate. If the underlying credential-sending bug in the TUI is distinct from the server-side auth rejection, both are worth tracking separately.

  2. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report! I reproduced this on 2.0.5. A password-protected server answers the client's health check with a 401 that has no body, so the client can't tell it's an authentication error. Instead of saying a password is needed, it fails with the generic did not provide a compatible V2 health response ... UnsupportedContentType.

    On the latest dev (950111ff2) the server's 401 says what it is, and opencode --server <url> now fails with Server at <url> requires a password; set OPENCODE_PASSWORD. So this is likely already fixed, and the fix should be in the next release.

    On both versions, the TUI takes the password from the environment rather than from the URL. This works on 2.0.5 too:

    OPENCODE_PASSWORD=<pass> opencode --server http://127.0.0.1:4096

    If you also want URL credentials (user:pass@ or ?auth_token=) to work for the TUI, please open a separate feature request.

    Related: #55558 (docs request for server deployment and passwords).

    The bot will close this issue in 1 day unless you reply that it still happens, e.g. on a newer version.

  3. alex-mashin commented on Oct 28, 2026

    @alex-mashin

    This is likely to be caused by #45856. It is not fixed and this is time that a human attends to the bug.

  4. opencodejr commented on Oct 29, 2026

    @opencodejr
    Contributor

    Closing this as completed, since there's been no reply in the day since the last update. On 2.0.5, a password-protected server's 401 has no body, so opencode --server showed the generic UnsupportedContentType health-check error. On the latest dev (950111ff2) it says requires a password; set OPENCODE_PASSWORD instead, so the fix should be in the next release. Until then, setting OPENCODE_PASSWORD=<pass> in the shell where you run opencode --server lets the TUI connect.

    If this still happens on a newer version, please comment here or open a new issue. If you'd like the TUI to accept credentials in the URL, a separate feature request is welcome. Thanks for the detailed report!

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions