-
Notifications
You must be signed in to change notification settings - Fork 224
fix: build assignment queries #1697
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
Conversation
packages/db/queries/builds/get_exclusive_builds_for_template_deletion.sql
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
infra/packages/api/internal/handlers/template_delete.go
Lines 40 to 42 in 001dbf4
| if len(builds) == 0 { | |
| telemetry.ReportError(ctx, "template not found", nil, telemetry.WithTemplateID(aliasOrTemplateID)) | |
| a.sendAPIStoreError(c, http.StatusNotFound, fmt.Sprintf("Template '%s' not found or you don't have access to it", aliasOrTemplateID)) |
The new deletion flow treats len(builds) == 0 as “template not found,” but GetExclusiveBuildsForTemplateDeletion only returns builds that are exclusive to the template. If a template exists but all its builds are shared with other templates (or it has no build assignments yet), the query will return zero rows and this handler now returns 404, preventing deletion of a valid template. This is a behavioral regression from the previous left-join query, which allowed deletion even when there were no deletable builds.
ℹ️ 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".
e71d639 to
4524338
Compare
Note
Aligns API/DB around tag-aware build selection and assignment ordering, and simplifies build status updates.
default) and order by assignmentcreated_atacross queries (snapshots,team templates, in-progress builds, template builds)template_idrequirement from build status updates (UpdateEnvBuildStatus,FinishTemplateBuild), updating API/template-manager callers accordinglyGetExclusiveBuildsForTemplateDeletionand use it in template delete handler to safely clean up builds only owned by the templateRegisterBuild, invalidate unstarted builds per provided tags; ensure default tag is applied when none providedGetTemplateWithBuildByTag; supportid:tagparsing in template creationDISTINCT/ordering fixes to avoid duplicatespackages/dbinto CI and addmake testtargetWritten by Cursor Bugbot for commit ce8cb01. This will update automatically on new commits. Configure here.