Skip to content

fix(coderd/provisionerdserver): ensure that SidebarAppID is a known workspace app #19123

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Aug 2, 2025

Relates to #18776

Applies a quick and dirty 'workaround' when the sidebar app ID references an unknown app ID for the build.

@johnstcn johnstcn self-assigned this Aug 2, 2025
@johnstcn johnstcn changed the title fix(coderd/provisionerdserver): ensure that SidebarAppID is a known w… fix(coderd/provisionerdserver): ensure that SidebarAppID is a known workspace app Aug 2, 2025
Copy link
Contributor

@hugodutka hugodutka left a comment

Choose a reason for hiding this comment

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

I reproduced the issue and can confirm that this fix allows the workspace build to complete. I'm concerned, though, that it hides the error from the user. We have a report from a user who ran into this during the start transition, and with this fix, the task will immediately disappear from the UI list after creation, which will be confusing. Still, I suppose that's better than leaving the workspace in a failed, stuck state.

@@ -1959,18 +1970,33 @@ func (s *server) completeWorkspaceBuildJob(ctx context.Context, job database.Pro
sidebarAppID = uuid.NullUUID{UUID: id, Valid: true}
}

// NOTE(Cian): If stopping a workspace build, we must ensure that the
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also note that this is a hack to get around a fatal error triggered by the bug I described here: #18776 (comment)

// 'silently' not configured as an AI task except for a warning in the logs.
// Ideally, we should also accept an app slug as these are less likely to change.
if sidebarAppID.Valid && !slices.Contains(knownAppIDs, sidebarAppID.UUID.String()) {
s.Logger.Warn(ctx, "workspace build has unknown sidebar app ID",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd reference the issue in the log. A user has reported this problem also occurring during the start transition. With this fix, after a user spawns a task, they'll see it immediately disappear after creation and will wonder where it went. When they look at server logs, let's explain the problem and point them where to look next.

Suggested change
s.Logger.Warn(ctx, "workspace build has unknown sidebar app ID",
s.Logger.Error(ctx, "task creation failed. Workspace build has unknown sidebar app ID - this is a known issue. See https://github.com/coder/coder/issues/18776 for a workaround.",

@spikecurtis
Copy link
Contributor

It doesn't seem right that our database schema requires a sidebar app ID to STOP the workspace. Generally on a STOP, you don't have any agents, meaning you won't have any coder_apps. Were we depending on a previous build including the app ID for this to work?

Also, what's the overall game plan for this "workaround"? It doesn't seem like a permanent solution. Is the idea that we will patch and then get a proper solution going? Do we have a sense for how long a proper solution will take? I.e. can we just do the real fix without mucking around with a patch release?

Copy link
Contributor

@spikecurtis spikecurtis left a comment

Choose a reason for hiding this comment

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

I think this is going to be noticable to everyone using AI Tasks in a bad way. See inline comment.

This issue comment sketches out what I think the correct fix is: #18776 (comment)

slog.F("known_app_ids", knownAppIDs),
)
sidebarAppID = uuid.NullUUID{}
hasAITask = false
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will trigger on basically every workspace stop, since generally speaking, stop transitions won't have any agents. So, every time you stop an AI Task it will disappear.

Has anyone tested this out end to end? Am I wrong about this always triggering on stop?

Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't always trigger on stop, and it sometimes triggers on start transitions too. See #18776 (comment)

Base automatically changed from cj/chore/provisionerdserver-no-disable-foreign-key-checks to main August 4, 2025 20:51
@johnstcn
Copy link
Member Author

johnstcn commented Aug 4, 2025

Will investigate an alternative solution that does not result in silently unsetting the has_ai_task flag.

@johnstcn johnstcn closed this Aug 4, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Aug 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants