Skip to content

Conversation

@ben-fornefeld
Copy link
Member

@ben-fornefeld ben-fornefeld commented Feb 9, 2026

Note

Medium Risk
Touches build listing/lookup queries and alias resolution logic, which could change which builds are returned or how they’re labeled; overall behavior should be equivalent but depends on the new join data being present and correct.

Overview
Updates build listing and lookup to use the new env_build_assignments join instead of env_builds.env_id, including team scoping, filtering by template, and fetching aliases separately for display.

Refactors listBuilds to resolve template IDs by either ID or alias, handle the “build UUID vs template” ambiguity via merged queries, and centralizes query construction/cursor filtering.

Separately normalizes spec/openapi.infra.yaml quoting (response codes and $refs) and updates generated DB types to match current Supabase schema metadata.

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

@vercel
Copy link

vercel bot commented Feb 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
web Ready Ready Preview, Comment Feb 12, 2026 3:41am
web-juliett Ready Ready Preview, Comment Feb 12, 2026 3:41am

Request Review

@ben-fornefeld ben-fornefeld added the enhancement New feature or request label Feb 9, 2026
@ben-fornefeld ben-fornefeld changed the title Refactor: Update envs queries to account for env_assignments relation migration Refactor: Update envs queries to account for env_build_assignments relation migration Feb 9, 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

Here are some automated review suggestions for this pull request.

Reviewed commit: 010a73d879

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 101 to 102
query = query.or(
`env_build_assignments.env_id.eq.${resolvedEnvId},id.eq.${buildIdOrTemplate}`

Choose a reason for hiding this comment

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

P1 Badge Split UUID template lookup from cross-table OR filter

When buildIdOrTemplate is a template UUID, this branch builds or(env_build_assignments.env_id...,id...), which mixes an embedded-table predicate with a top-level predicate in one or clause. In that path, template-id searches can fail or return incorrect rows because the relation-scoped condition is not reliably evaluated alongside the base-table condition; this is the hot path for UUID template filters and should be split into separate filters/queries.

Useful? React with 👍 / 👎.

build: RawListedBuildWithEnvAndAliasesDB
): ListedBuildDTO {
const alias = build.envs.env_aliases?.[0]?.alias
const assignment = build.env_build_assignments[0]

Choose a reason for hiding this comment

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

P2 Badge Choose assignment deterministically before deriving templateId

This mapping takes env_build_assignments[0] without any ordering or context filter, so builds with multiple assignments can be labeled with an arbitrary template/templateId depending on returned row order. That makes build rows unstable and can route users to the wrong template context in downstream build-detail/log flows.

Useful? React with 👍 / 👎.

@ben-fornefeld ben-fornefeld force-pushed the refactor/envs-assignments-relation-migration branch from feb4cdc to ec70993 Compare February 10, 2026 19:31
- Removed unnecessary team_id from envs in RawListedBuildWithEnvAndAliasesDB type.
- Updated build query functions to utilize a new helper for fetching team environment IDs.
- Adjusted listBuilds and getBuildInfo functions to filter builds based on team-specific environment IDs.
- Enhanced error handling for cases where no environments are found for a team.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


if (statuses.length < ALL_BUILD_STATUSES.length) {
query = query.in('status', statuses)
}
Copy link

Choose a reason for hiding this comment

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

Length-based status filter skipped on duplicate statuses

Medium Severity

The conditional statuses.length < ALL_BUILD_STATUSES.length uses array length to decide whether to apply the status filter. The caller in the router uses flatMap(mapBuildStatusDTOToDatabaseBuildStatus), which expands 'building' into ['building', 'waiting']. If the client sends duplicate DTO statuses (e.g., ['building', 'building']), the flattened array has 4 elements — equal to ALL_BUILD_STATUSES.length — so the filter is incorrectly skipped, returning builds of all statuses. The old code always applied .in('status', statuses), where SQL's IN clause naturally deduplicates.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant