Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc8583d8

Browse files
fix(coderd): allow fetching a newly created task
Due to how we currently label a workspace as a task, there is a delaybetween when a task workspace is created and when it is labelled asa task.This PR introduces fallback check for when a workspace does _not_ have`HasAITask` set. This fallback check tests to see if the special "AIPrompt" parameter is present in the workspace's build parameters.
1 parent06cbb28 commitc8583d8

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

‎coderd/aitasks.go‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,36 @@ func (api *API) taskGet(rw http.ResponseWriter, r *http.Request) {
440440
return
441441
}
442442
ifdata.builds[0].HasAITask==nil||!*data.builds[0].HasAITask {
443-
httpapi.ResourceNotFound(rw)
444-
return
443+
// TODO(DanielleMaywood):
444+
// This is a temporary workaround. When a task has just been created, but
445+
// not yet provisioned, the workspace build will not have `HasAITask` set.
446+
//
447+
// When we reach this code flow, it is _either_ because the workspace is
448+
// not a task, or it is a task that has not yet been provisioned. This
449+
// endpoint should rarely be called with a non-task workspace so we
450+
// should be fine with this extra database call to check if it has the
451+
// special "AI Task" parameter.
452+
parameters,err:=api.Database.GetWorkspaceBuildParameters(ctx,data.builds[0].ID)
453+
iferr!=nil {
454+
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
455+
Message:"Internal error fetching workspace build parameters.",
456+
Detail:err.Error(),
457+
})
458+
return
459+
}
460+
461+
hasAITask:=false
462+
for_,parameter:=rangeparameters {
463+
ifparameter.Name==codersdk.AITaskPromptParameterName {
464+
hasAITask=true
465+
break
466+
}
467+
}
468+
469+
if!hasAITask {
470+
httpapi.ResourceNotFound(rw)
471+
return
472+
}
445473
}
446474

447475
appStatus:= codersdk.WorkspaceAppStatus{}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp