Skip to content

fix(migration): exclude _skills sentinel from F2 cross-org verify#57

Merged
kaje94 merged 1 commit into
cloud-testfrom
fix/f2-skills-sentinel-verify
Jun 24, 2026
Merged

fix(migration): exclude _skills sentinel from F2 cross-org verify#57
kaje94 merged 1 commit into
cloud-testfrom
fix/f2-skills-sentinel-verify

Conversation

@kaje94

@kaje94 kaje94 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Problem

app-factory-api (BFF) is in CrashLoopBackOff on the cloud-cp dev cluster. It dies during the startup DB migration, not at runtime:

ERROR git_repositories composite-unique (F2) migration failed
  error: F2 aborted: 1 project_id value(s) span multiple orgs;
         resolve the collisions before dropping the global unique

main.go treats the migration error as fatal (os.Exit(1)) → crash loop.

Root cause

The F2 migration (git_repo_composite_unique.go) replaces the global UNIQUE(project_id) with composite UNIQUE(org_id, project_id) via expand → verify → contract. The verify step aborts if any project_id spans multiple orgs, on the assumption "the old global unique guaranteed it cannot."

That assumption is false because of the skills sentinel: the skills feature stores one git_repositories row per org with project_id = "_skills" (models.SkillsRepoSentinelProjectID), created lazily by ensureSkillsRepo. So _skills legitimately spans every org. Once ≥2 orgs have a skills repo, the verify guard miscounts the sentinel as a cross-org collision and aborts forever — no data fix helps, since per-org _skills is by design and gets re-created on use.

Confirmed on the dev DB: the only spanning value is _skills (orgs anjana112, anjanas), and the table is already in the target end-state — composite unique ux_git_repositories_org_project present, old global unique idx_git_repositories_project_id already absent. The expand/contract steps are no-ops; only the verify guard blocks startup.

Fix

Exclude the sentinel from the verify query (WHERE project_id <> models.SkillsRepoSentinelProjectID). Real project-repo collisions are still caught and still abort. No data change.

Testing

  • go build ./database/migrations/ passes.
  • Ran the patched verify query against the live dev DB → returns 0, so the migration would proceed and the pod would boot.

🤖 Generated with Claude Code

The git_repositories composite-unique (F2) migration aborts startup if any
project_id spans multiple orgs. But the per-org skills sentinel
(SkillsRepoSentinelProjectID = "_skills") is one row per org by design, so it
legitimately spans every org. On any deployment where >=2 orgs have a skills
repo, the verify guard miscounts the sentinel as a cross-org collision and
os.Exit(1)s the BFF into CrashLoopBackOff.

Exclude the sentinel from the verify query so only real project repos are
checked against the old global-unique invariant before it is dropped. No data
change; the DB is already in the target end-state (composite unique present,
global unique already absent).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b94f4d46-c9b0-4d81-99c6-52c08b400df0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/f2-skills-sentinel-verify

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kaje94 kaje94 merged commit 3892561 into cloud-test Jun 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant