Skip to content

fix(agent-server): ignore empty VS Code tkn on resource requests - #6804

Open
aribaskagan wants to merge 1 commit into
OpenHands:mainfrom
aribaskagan:fix-code-server-empty-tkn
Open

aribaskagan wants to merge 1 commit into
OpenHands:mainfrom
aribaskagan:fix-code-server-empty-tkn

Conversation

@aribaskagan

Copy link
Copy Markdown

HUMAN:

Found the empty tkn check in the proxy and tested the fix against a live code-server


AGENT:

Why

Embedded VS Code in agent-canvas 1.40 loads, but theme, grammar, and extension fetches to /vscode/stable-…/vscode-remote-resource?path=…&tkn= return 401. code-server appends an empty tkn on those URLs. The editor proxy treated any tkn query parameter as the session-token exchange, so the empty value failed the constant-time compare and returned 401 before the HttpOnly editor cookie was checked.

Summary

  • Only a non-empty tkn is the handshake. A match still sets the editor cookie and returns 303. A mismatch still returns 401.
  • An empty or absent tkn falls through to the existing cookie check and is proxied. vscode-remote-resource stays authenticated by that cookie.

Issue Number

Fixes #6803 (downstream report: OpenHands/OpenHands#19713)

How to Test

uv run pytest tests/agent_server/test_code_server_proxy.py -q
CODE_SERVER_ROOT=/path/to/code-server-4.145.0 \
  uv run pytest tests/agent_server/test_code_server_live.py -q

The proxy test needs Node. The live test needs an extracted code-server release. After a valid ?tkn=<token> exchange, …/vscode-remote-resource?path=…&tkn= with the editor cookie returns 200 (the live test serves dark_plus.json and expects Dark+). The same URL without the cookie returns 401. tkn=<wrong> returns 401.

Video/Screenshots

N/A. The failure is an HTTP 401 on vscode-remote-resource, covered by the tests above.

Design Doc

Skipped. This is a small bug fix in the existing editor-proxy handshake.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

This change was written with AI assistance.

Draft #6195 changes how the connection token is passed on argv. It does not change this proxy handshake.

code-server appends an empty tkn query parameter on vscode-remote-resource
URLs. The editor proxy treated any tkn parameter as the session-token
exchange, so the empty value failed the compare and returned 401 before
the editor cookie was checked.

Only a non-empty tkn is the handshake. An empty or absent tkn falls
through to the cookie check and is proxied.

See OpenHands/OpenHands#19713
Copilot AI balanced review requested due to automatic review settings November 13, 2026 17:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants