Skip to content

Conversation

@dobrac
Copy link
Contributor

@dobrac dobrac commented Jan 8, 2026

Note

Aligns API/DB around tag-aware build selection and assignment ordering, and simplifies build status updates.

  • Enforce tag-aware lookups (primarily default) and order by assignment created_at across queries (snapshots, team templates, in-progress builds, template builds)
  • Remove template_id requirement from build status updates (UpdateEnvBuildStatus, FinishTemplateBuild), updating API/template-manager callers accordingly
  • Add GetExclusiveBuildsForTemplateDeletion and use it in template delete handler to safely clean up builds only owned by the template
  • In RegisterBuild, invalidate unstarted builds per provided tags; ensure default tag is applied when none provided
  • Replace alias-based base-template lookup with tag-aware GetTemplateWithBuildByTag; support id:tag parsing in template creation
  • Add DB migration to optimize indexes for build assignments; add DISTINCT/ordering fixes to avoid duplicates
  • Expand unit/integration tests for tag reassignment, latest-assignment semantics, invalidation by tag, and exclusive-builds; wire packages/db into CI and add make test target

Written by Cursor Bugbot for commit ce8cb01. This will update automatically on new commits. Configure here.

@dobrac dobrac added the bug Something isn't working label Jan 8, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

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))

P2 Badge Don’t treat “no exclusive builds” as “template missing”

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".

@dobrac dobrac force-pushed the fix/build-assignment-queries branch from e71d639 to 4524338 Compare January 8, 2026 12:42
@dobrac dobrac merged commit 153aefb into main Jan 8, 2026
30 checks passed
@dobrac dobrac deleted the fix/build-assignment-queries branch January 8, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants