Skip to content

Commit 4044e0d

Browse files
committed
fix: resolve agent only after workspace was resolved
Switched the order of the steps, the agent and hist state is resolved only after the workspace was resolved and after it was in a running state. Otherwise URI handling during workspace startup could provide misleading errors related to agent not existing or not being ready.
1 parent e3c76f6 commit 4044e0d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ open class CoderProtocolHandler(
5858
val workspaceName = resolveWorkspaceName(params) ?: return
5959
val restClient = buildRestClient(deploymentURL, token) ?: return
6060
val workspace = restClient.workspaces().matchName(workspaceName, deploymentURL) ?: return
61-
val agent = resolveAgent(params, workspace) ?: return
62-
6361
if (!prepareWorkspace(workspace, restClient, workspaceName, deploymentURL)) return
62+
63+
// we resolve the agent after the workspace is started otherwise we can get misleading
64+
// errors like: no agent available while workspace is starting or stopping
65+
val agent = resolveAgent(params, workspace) ?: return
6466
if (!ensureAgentIsReady(workspace, agent)) return
6567

6668
val cli = configureCli(deploymentURL, restClient)

0 commit comments

Comments
 (0)