Skip to content

[Bug]: agent-server editor proxy returns 401 for code-server resources with empty tkn (themes/grammars missing) #6803

Open

Description

@aribaskagan

Is there an existing issue for the same bug?

  • I have searched existing issues and this is not a duplicate.

Bug Description

Reported downstream in OpenHands/OpenHands#19713. Since the runtime moved from openvscode-server to code-server (canvas 1.37 to 1.40), the embedded VS Code loads but theme, grammar and extension files fail with 401, so the editor falls back to the light theme with no syntax highlighting.

Root cause: code-server requests those files as /vscode/stable-.../vscode-remote-resource?path=...&tkn= with an empty tkn. In openhands-agent-server/openhands/agent_server/code_server_proxy.cjs the proxy checks url.searchParams.has("tkn"), so the empty value is treated as the session-token exchange, fails the compare against config.token, and returns 401 before the editor cookie is checked.

Expected Behavior

After the normal ?tkn=<session key> exchange sets the editor cookie, resource requests that carry an empty tkn are authenticated by that cookie and proxied to code-server.

Actual Behavior

GET .../vscode-remote-resource?path=...&tkn= returns 401 even with a valid editor cookie.

Steps to Reproduce

  1. Run agent-canvas 1.40 (agent-server 1.62.0) and open a conversation's VS Code tab
  2. Open the browser devtools network tab
  3. See vscode-remote-resource?...&tkn= requests return 401; dark theme and syntax highlighting are missing

Acceptance Criteria

  • After a valid tkn exchange, vscode-remote-resource?...&tkn= with the editor cookie returns 200
  • The same URL without the cookie still returns 401
  • A wrong non-empty tkn still returns 401

Installation Method

No response

If you selected "Other", please specify

No response

SDK Version

main (e454a86), agent-server 1.62.0

Version Confirmation

  • I have confirmed this bug exists on the LATEST version of OpenHands SDK

Python Version

No response

Model Name (if applicable)

No response

Operating System

No response

Logs and Error Messages

No response

Minimal Code Sample

No response

Evidence and Additional Context

Proposed fix: only treat a non-empty tkn as the handshake. A matching token keeps the current Set-Cookie + 303, a wrong non-empty token stays 401, and an empty or missing tkn falls through to the existing cookie check. I have this fix with proxy and live code-server tests ready on a branch and can open a PR once this is marked ready-for-dev.


OpenHands AI triage

The following comments and acceptance criteria were added by the OpenHands AI agent.

Triage

Verified against openhands-agent-server/openhands/agent_server/code_server_proxy.cjs: the handshake branch checks url.searchParams.has("tkn"), so code-server resource requests of the form /vscode-remote-resource?...&tkn= (empty value) are treated as the token exchange, fail the compare against config.token, and return 401 before the editor cookie is checked — exactly as reported. A real user hit this after the openvscode-server to code-server migration (OpenHands/OpenHands#19713), so this is prioritized medium. Scope is minimal: only the empty-tkn request path changes — non-empty tkn behavior stays exactly as today, and empty/missing tkn falls through to the existing cookie check. Non-goals: no redesign of the handshake or cookie scheme, no changes to the session-token exposure model (tracked separately by #4317), no Agent Canvas UI changes, and no work on the unrelated code-server "File not found" (vsda) log lines seen in the downstream report. Validation reuses the existing code-server proxy auth tests and the opt-in live test (tests/agent_server/test_code_server_live.py, CODE_SERVER_ROOT) instead of introducing a new mechanism.

Acceptance Criteria

  • After a valid tkn=<session key> exchange sets the editor cookie, GET /vscode/<release>/vscode-remote-resource?path=...&tkn= (empty tkn) with that cookie returns 200 and is proxied to code-server, so theme, grammar, and extension assets load in the embedded editor
  • The same vscode-remote-resource URL with an empty or missing tkn and no editor cookie returns 401 (an empty tkn never authenticates by itself)
  • The same URL with a wrong non-empty tkn returns 401
  • The handshake path is unchanged: a correct non-empty tkn still returns 303 with Set-Cookie and a redirect target without tkn; a wrong non-empty tkn still returns 401 without setting a cookie
  • The empty-tkn-with-cookie case is covered by the code-server proxy auth tests and, when CODE_SERVER_ROOT is provided, by tests/agent_server/test_code_server_live.py extended for both a default and a non-default server_base_path prefix

Activity

  1. added
    bug
    on Nov 13, 2026
  2. added
    priority:medium
    ready-for-dev
    on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority:mediumready-for-dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions