mirror of
https://github.com/coder/coder.git
synced 2026-06-03 04:58:23 +00:00
fix: return 409 Conflict instead of 502 when task agent is busy (#23424)
The "Task app is not ready to accept input" error occurs when the agent responds successfully but its status is not "stable" (e.g. "running"). This is a state conflict, not a gateway error. 502 was semantically wrong because the gateway communication succeeded. 409 Conflict is correct because the request conflicts with the agent's current state. This is consistent with how authAndDoWithTaskAppClient already returns 409 for pending, initializing, and paused agent states.
This commit is contained in:
committed by
GitHub
parent
69d430f51b
commit
75f5b60eb6
@@ -789,6 +789,11 @@ func TestTasks(t *testing.T) {
|
||||
})
|
||||
require.Error(t, err, "wanted error due to bad status")
|
||||
|
||||
var sdkErr *codersdk.Error
|
||||
require.ErrorAs(t, err, &sdkErr)
|
||||
require.Equal(t, http.StatusConflict, sdkErr.StatusCode())
|
||||
require.Contains(t, sdkErr.Message, "not ready to accept input")
|
||||
|
||||
statusResponse = agentapisdk.StatusStable
|
||||
|
||||
//nolint:tparallel // Not intended to run in parallel.
|
||||
|
||||
Reference in New Issue
Block a user