Repository navigation
Description
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
- Run agent-canvas 1.40 (agent-server 1.62.0) and open a conversation's VS Code tab
- Open the browser devtools network tab
- See
vscode-remote-resource?...&tkn=requests return 401; dark theme and syntax highlighting are missing
Acceptance Criteria
- After a valid
tknexchange,vscode-remote-resource?...&tkn=with the editor cookie returns 200 - The same URL without the cookie still returns 401
- A wrong non-empty
tknstill 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=(emptytkn) 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-resourceURL with an empty or missingtknand no editor cookie returns 401 (an emptytknnever authenticates by itself) - The same URL with a wrong non-empty
tknreturns 401 - The handshake path is unchanged: a correct non-empty
tknstill returns 303 withSet-Cookieand a redirect target withouttkn; a wrong non-emptytknstill returns 401 without setting a cookie - The empty-
tkn-with-cookie case is covered by the code-server proxy auth tests and, whenCODE_SERVER_ROOTis provided, bytests/agent_server/test_code_server_live.pyextended for both a default and a non-defaultserver_base_pathprefix
Activity