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

fix(coderd): filter out non-task workspaces in api.tasksList#19559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 1 commit intomainfromcj/exp-task-list-filter
Aug 27, 2025

Conversation

johnstcn
Copy link
Member

@johnstcnjohnstcn commentedAug 26, 2025
edited
Loading

Quick fix for following issue in CLI:

$ go run ./cmd/coder exp task listEncountered an error running "coder exp task list", see "coder exp task list --help" for more informationerror: Trace=[list tasks: ]Internal error fetching task prompts and states.workspace 14d548f4-aaad-40dd-833b-6ffe9c9d31bc is not an AI task workspaceexit status 1

This occurs in a short time window directly after creating a new task.

I took a stab at writing a test for this, but ran out of time. I'm not entirely sure what causes non-AI-task workspaces to be returned in the query but I suspect it's when a workspace build is pending or running.

filtered=append(filtered,ws)
}
}
tasks,err:=api.tasksFromWorkspaces(ctx,filtered)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think it’s worth finding a proper fix for this as filtering here breaks pagination.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Maybe we could always add the filterhas-ai-task:true?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We already do that 🤔

@DanielleMaywood
Copy link
Contributor

I suspect this is the root cause

If the build has no AI task, it means that the provisioner job is in progress
and we don't know if it has an AI task yet. In this case, we optimistically
assume that it has an AI task if the AI Prompt parameter is not empty.
lets the AI Task frontend spawn a task and see it immediately after instead of
having to wait for the build to complete.

https://github.com/coder/coder/blob/8083d9d5c87fbb7d7d8f018706a8d0769480378a/coderd/database/queries/workspaces.sql#L357C1-L372C46

So we're potentially returning workspaces that do not yet havehas_ai_task set

@mafredri
Copy link
Member

I suspect this is the root cause

If the build has no AI task, it means that the provisioner job is in progress
and we don't know if it has an AI task yet. In this case, we optimistically
assume that it has an AI task if the AI Prompt parameter is not empty.
lets the AI Task frontend spawn a task and see it immediately after instead of
having to wait for the build to complete.

8083d9d/coderd/database/queries/workspaces.sql#L357C1-L372C46

So we're potentially returning workspaces that do not yet havehas_ai_task set

@DanielleMaywood that does indeed look like it would be the culprit. We definitely need to improve how tasks are detected so there can't be any flip-flopping between states.

@johnstcn
Copy link
MemberAuthor

We definitely need to improve how tasks are detected so there can't be any flip-flopping between states.

Honestly I think the 'correct' fix here is to have tasks defined separately to workspaces.

@mafredri
Copy link
Member

Honestly I think the 'correct' fix here is to have tasks defined separately to workspaces.

I definitely agree. I don't think that excludes an interim fix, though. For now we could relax the "ai task" constraint to match that of the query.

I.e. intasksFromWorkspaces remove:

for _, ws := range apiWorkspaces {if ws.LatestBuild.HasAITask == nil || !*ws.LatestBuild.HasAITask {return nil, xerrors.Errorf("workspace %s is not an AI task workspace", ws.ID)}}

@johnstcnjohnstcnforce-pushed thecj/exp-task-list-filter branch from83eb368 to81fb1d5CompareAugust 27, 2025 11:16
@johnstcn
Copy link
MemberAuthor

Honestly I think the 'correct' fix here is to have tasks defined separately to workspaces.

I definitely agree. I don't think that excludes an interim fix, though. For now we could relax the "ai task" constraint to match that of the query.

I.e. intasksFromWorkspaces remove:

for _, ws := range apiWorkspaces {if ws.LatestBuild.HasAITask == nil || !*ws.LatestBuild.HasAITask {return nil, xerrors.Errorf("workspace %s is not an AI task workspace", ws.ID)}}

Sounds good to me, it appears to work locally also:

cdr-mbp-jmqxfj0746:coder cian$ ./scripts/coder-dev.sh exp tasks create --input hello tasks && ./scripts/coder-dev.sh exp tasks listThe task task-crazy-williamson-34b8 has been created at Aug 27 12:19:37!ID                                    NAME                        STATUS    STATE  STATE CHANGED  MESSAGE5bdfa8ee-55fd-4d9c-bd63-212176d6a5b3  task-crazy-williamson-34b8  starting  <nil>                 <nil>69a7e749-37ea-48c7-88a4-6ed78e737459  task-youthful-pare-6c73     running   <nil>                 <nil>
mafredri reacted with hooray emoji

@johnstcnjohnstcn merged commitdbc6c98 intomainAug 27, 2025
26 checks passed
@johnstcnjohnstcn deleted the cj/exp-task-list-filter branchAugust 27, 2025 14:32
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsAug 27, 2025
@johnstcnjohnstcn added the cherry-pick/v2.26Needs to be cherry-picked to the 2.26 release branch labelAug 27, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri approved these changes

@DanielleMaywoodDanielleMaywoodDanielleMaywood approved these changes

Assignees

@johnstcnjohnstcn

Labels
cherry-pick/v2.26Needs to be cherry-picked to the 2.26 release branch
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@johnstcn@DanielleMaywood@mafredri

[8]ページ先頭

©2009-2025 Movatter.jp