diff --git a/coderd/workspaceagents.go b/coderd/workspaceagents.go index cc05ecc73d3ef..b881e337906ba 100644 --- a/coderd/workspaceagents.go +++ b/coderd/workspaceagents.go @@ -1126,7 +1126,7 @@ func convertWorkspaceAgent(derpMap *tailcfg.DERPMap, coordinator tailnet.Coordin ConnectionTimeoutSeconds: dbAgent.ConnectionTimeoutSeconds, TroubleshootingURL: troubleshootingURL, LifecycleState: codersdk.WorkspaceAgentLifecycle(dbAgent.LifecycleState), - LoginBeforeReady: dbAgent.StartupScriptBehavior == database.StartupScriptBehaviorNonBlocking, + LoginBeforeReady: dbAgent.StartupScriptBehavior != database.StartupScriptBehaviorBlocking, StartupScriptBehavior: codersdk.WorkspaceAgentStartupScriptBehavior(dbAgent.StartupScriptBehavior), StartupScriptTimeoutSeconds: dbAgent.StartupScriptTimeoutSeconds, ShutdownScript: dbAgent.ShutdownScript.String, diff --git a/codersdk/workspaceagents.go b/codersdk/workspaceagents.go index dcede6a069f4f..b99185bd7cc8d 100644 --- a/codersdk/workspaceagents.go +++ b/codersdk/workspaceagents.go @@ -375,7 +375,18 @@ func (c *Client) WorkspaceAgent(ctx context.Context, id uuid.UUID) (WorkspaceAge return WorkspaceAgent{}, ReadBodyAsError(res) } var workspaceAgent WorkspaceAgent - return workspaceAgent, json.NewDecoder(res.Body).Decode(&workspaceAgent) + err = json.NewDecoder(res.Body).Decode(&workspaceAgent) + if err != nil { + return WorkspaceAgent{}, err + } + // Backwards compatibility for cases where the API is older then the client. + if workspaceAgent.StartupScriptBehavior == "" { + workspaceAgent.StartupScriptBehavior = WorkspaceAgentStartupScriptBehaviorNonBlocking + if !workspaceAgent.LoginBeforeReady { + workspaceAgent.StartupScriptBehavior = WorkspaceAgentStartupScriptBehaviorBlocking + } + } + return workspaceAgent, nil } type IssueReconnectingPTYSignedTokenRequest struct {