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): disallow POSTing a workspace build on a deleted workspace#20584

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/no-post-workspacebuild-deleted-workspace
Oct 30, 2025

Conversation

@johnstcn
Copy link
Member

@johnstcnjohnstcn commentedOct 30, 2025
edited
Loading

Problem

It looks like, for a good long while, we have allows POSTing a workspace build on a deleted workspace. As far as I can tell, this goesway back (to at least 2.21, but maybe earlier).

Credit to@DanielleMaywood

Impact

  • You can "start" a deleted workspace if you would have previously had access to it (either due to your role or owning the workspace) and know its ID.
  • It won't show up in the UI.
  • Resources will be created (most likely re-created due to the previous DELETE transition).
  • The agent won't connect so you won't be able to access the resources via coder.

Proposed Solution

This PR adds a check on/api/v2/workspacebuilds to disallow creating a START or STOP build if the workspace is deleted. I elected to allow a DELETE build however.

Remediation

I haven't added any automatic remediation, but below is a (Claude-coded) SQL query that should show affected workspaces and associated resources:

WITH successful_deletesAS (SELECTwb.workspace_id,wb.created_atas delete_time,wb.idas delete_build_idFROM workspace_builds wbJOIN provisioner_jobs pjONwb.job_id=pj.idWHEREwb.transition='delete'ANDpj.completed_atIS NOT NULLANDpj.error ISNULL  )SELECTw.idas workspace_id,u.username||'/'||w.nameas workspace,wb.idas violating_build_id,wb.transitionas violating_transition,wb.created_atas violating_build_time,sd.delete_time,sd.delete_build_id,wb.created_at-sd.delete_timeas time_after_delete,    COALESCE(      string_agg(        DISTINCTwr.name||' ('||wr.type||')',','ORDER BYwr.name||' ('||wr.type||')'      ),'No resources'    )as workspace_resourcesFROM workspace_builds wbJOIN successful_deletes sdONwb.workspace_id=sd.workspace_idJOIN workspaces wONwb.workspace_id=w.idJOIN users uONw.owner_id=u.idLEFT JOIN workspace_resources wrONwb.job_id=wr.job_idANDwr.type NOTLIKE'coder_%'WHEREwb.transitionIN ('start','stop')ANDwb.created_at>sd.delete_timeGROUP BYw.id,w.name,u.username,wb.id,wb.transition,wb.created_at,sd.delete_time,sd.delete_build_idORDER BYwb.created_atDESC;

@johnstcnjohnstcn self-assigned thisOct 30, 2025
@deansheather
Copy link
Member

I think allowing extradelete transitions on a deleted workspace is fine but I don't think we should elevate it/support it in the CLI/UI (something Cian mentioned he was thinking of potentially adding in DMs).

  1. A successfuldelete transition will doterraform destroy which deletes all resources anyway, so any additional destroys (even on a different template version) will do nothing.
  2. If a workspace was orphaned, it was built with an empty state, so it's effectively the same as point 1.

There are no other ways for a workspace to becomedeleted AFAIK.

Obviously, if someone uploaded a custom state on their build the story is a bit different, which is why I think it's fine to leave it in the API. But I don't think anyone will ever need to do it so I don't think we should add it to the CLI/UI.

@johnstcnjohnstcn merged commit3801701 intomainOct 30, 2025
42 checks passed
@johnstcnjohnstcn deleted the cj/no-post-workspacebuild-deleted-workspace branchOctober 30, 2025 13:32
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsOct 30, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@DanielleMaywoodDanielleMaywoodDanielleMaywood approved these changes

Assignees

@johnstcnjohnstcn

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@johnstcn@deansheather@DanielleMaywood

[8]ページ先頭

©2009-2025 Movatter.jp