Skip to content

fix(coderd/database): match workspace requester by owner ID when sorting - #32188

Merged
mafredri merged 1 commit into
mainfrom
mafredri/getworkspaces-requester-id
Nov 17, 2026
Merged

mafredri merged 1 commit into
mainfrom
mafredri/getworkspaces-requester-id

Conversation

@mafredri

@mafredri mafredri commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

The GetWorkspaces sort that puts the requester's favorite and own workspaces first matches the owner by username instead of by ID. Usernames are unique only among non-deleted users, and a deleted user keeps theirs. So a user who takes a deleted user's username sees that user's deleted workspaces and favorites sorted as their own in deleted:true listings. The new test reproduces this on main.

Matching by owner_id, as the sort did before #22290, has no such case. #22290 doesn't say why it switched to the username. The likely reason is the sqlc CTE bug. With the EXISTS (tasks) filter the query had at the time, sqlc without the coder/sqlc fix rejected the bare owner_id as ambiguous, and the username form avoided that. #29085 removed that filter and #32187 restores the fix, so the owner_id form generates with either sqlc.

Only deleted workspaces are affected through the API, because deleteUser refuses to delete a user who still has workspaces.

🤖 Created with the help of Coder Agents.

GetWorkspaces sorted the requester's own and favorite workspaces first
by comparing owner_username with the requester's username. Usernames
are unique only among non-deleted users, and deleting a user keeps the
username, so a new user with a deleted user's username saw the deleted
user's workspaces sorted as their own when listing deleted workspaces.
Compare owner_id with the requester ID instead.
@mafredri
mafredri temporarily deployed to main November 13, 2026 17:42 — with GitHub Actions Inactive
@mafredri
mafredri temporarily deployed to main November 13, 2026 17:42 — with GitHub Actions Inactive
@mafredri
mafredri temporarily deployed to main November 17, 2026 10:21 — with GitHub Actions Inactive
@mafredri

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T10:24:32.705180Z 03777ee Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mafredri
mafredri marked this pull request as ready for review November 17, 2026 10:24
@mafredri
mafredri temporarily deployed to main November 17, 2026 10:24 — with GitHub Actions Inactive
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 03777ee072

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@mafredri
mafredri merged commit c3ff770 into main Nov 17, 2026
61 of 62 checks passed
@mafredri
mafredri deleted the mafredri/getworkspaces-requester-id branch November 17, 2026 11:42
@mafredri
mafredri temporarily deployed to main November 17, 2026 11:42 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 17, 2026

This branch had an error being deployed

1 failed and 1 inactive deployments
main — 03777ee0 Deployed Nov 17, 2026 by mafredri via cla #258570
docs-preview — 03777ee0 Deployed Nov 17, 2026 by mafredri via cleanup #160
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.

2 participants