Skip to content

chore: switch agent gone response from 502 to 404 (backport #23090)#23636

Merged
f0ssel merged 1 commit intorelease/2.30from
rowan/fix/workspace_agent_502_2.30
Mar 25, 2026
Merged

chore: switch agent gone response from 502 to 404 (backport #23090)#23636
f0ssel merged 1 commit intorelease/2.30from
rowan/fix/workspace_agent_502_2.30

Conversation

@rowansmithau
Copy link
Copy Markdown
Member

Backport of #23090 to release/2.30.

When a user creates a workspace, opens the web terminal, then the workspace stops but the web terminal remains open, the web terminal will retry the connection. Coder would issue a HTTP 502 Bad Gateway response when this occurred because coderd could not connect to the workspace agent, however this is problematic as any load balancer sitting in front of Coder sees a 502 and thinks Coder is unhealthy.

This PR changes the response to a HTTP 404 after internal discussion.

Cherry-picked from merge commit c33812a.

When a user creates a workspace, opens the web terminal, then the
workspace stops but the web terminal remains open the web terminal will
retry the connection. Coder will issue a HTTP 502 Bad Gateway response
when this occurs because coderd cannot connect to the workspace agent,
however this is problematic as any load balancer sitting in front of
Coder sees a 502 and thinks Coder is unhealthy.

The main change is in
https://github.com/coder/coder/pull/23090/changes#diff-bbe3b56ed3532289481a0e977867cd15048b7ca718ce676aae3f3332378eebc2R97,
however the main test and downstream tests are also updated.

This PR changes the response to a [HTTP
404](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/404)
after internal discussion.

<img width="1832" height="1511" alt="image"
src="https://github.com/user-attachments/assets/0baff80d-bb98-4644-89cd-e80c87947098"
/>

Created with the help of Mux, reviewed and tested by a human
@github-actions github-actions bot added the community Pull Requests and issues created by the community. label Mar 25, 2026
@coder-tasks
Copy link
Copy Markdown
Contributor

coder-tasks bot commented Mar 25, 2026

Documentation Check

No Changes Needed

This PR changes the HTTP response status code from 502 to 404 when a workspace app is unavailable (agent offline). The change is an internal bug fix to prevent load balancers from misinterpreting Coder as unhealthy. No user-facing documentation, CLI flags, configuration options, or API contracts are affected. No existing docs reference this specific status code behavior.


Automated review via Coder Tasks

@rowansmithau rowansmithau requested a review from f0ssel March 25, 2026 19:57
@rowansmithau rowansmithau added cherry-pick/v2.30 Needs to be cherry-picked to the 2.30 release branch and removed community Pull Requests and issues created by the community. labels Mar 25, 2026
@f0ssel f0ssel merged commit 3b2ded6 into release/2.30 Mar 25, 2026
70 of 76 checks passed
@f0ssel f0ssel deleted the rowan/fix/workspace_agent_502_2.30 branch March 25, 2026 20:49
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cherry-pick/v2.30 Needs to be cherry-picked to the 2.30 release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants