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: use system context for querying workspaces when deleting users#19211

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

Conversation

ethanndickson
Copy link
Member

@ethanndicksonethanndickson commentedAug 7, 2025
edited
Loading

Closes#19209.

This fixes a bug where a user who has workspaces could be deleted, if the user doing the deleting couldn't view the workspace.

Intemplates.go, we do this to make sure we count ALL workspaces for a template before we try and delete that template:

// This is just to get the workspace count, so we use a system context to
// return ALL workspaces. Not just workspaces the user can view.
// nolint:gocritic
workspaces,err:=api.Database.GetWorkspaces(dbauthz.AsSystemRestricted(ctx), database.GetWorkspacesParams{
TemplateIDs: []uuid.UUID{template.ID},
})
iferr!=nil&&!errors.Is(err,sql.ErrNoRows) {
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
Message:"Internal error fetching workspaces by template id.",
Detail:err.Error(),
})
return
}
iflen(workspaces)>0 {
httpapi.Write(ctx,rw,http.StatusBadRequest, codersdk.Response{
Message:"All workspaces must be deleted before a template can be removed.",
})
return
}

However, we weren't doing the same when attempting to delete users, leading to the linked issue. We can solve the issue the same way as we do for templates.

@ethanndicksonGraphite App
Copy link
MemberAuthor

This stack of pull requests is managed byGraphite. Learn more aboutstacking.

@ethanndicksonethanndickson marked this pull request as ready for reviewAugust 7, 2025 03:35
@ethanndicksonethanndickson merged commit99d75cc intomainAug 7, 2025
33 checks passed
@ethanndicksonethanndickson deleted the ethan/sys-context-get-workspaces-delete-user branchAugust 7, 2025 06:31
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsAug 7, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@deansheatherdeansheatherdeansheather approved these changes

Assignees

@ethanndicksonethanndickson

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

bug: Users with "User Admin" role can delete users with workspaces
2 participants
@ethanndickson@deansheather

[8]ページ先頭

©2009-2025 Movatter.jp