Skip to content

fix(resource): reconcile #project/#owner relations on update#1686

Draft
whoAbhishekSah wants to merge 1 commit into
mainfrom
fix/resource-update-reconcile
Draft

fix(resource): reconcile #project/#owner relations on update#1686
whoAbhishekSah wants to merge 1 commit into
mainfrom
fix/resource-update-reconcile

Conversation

@whoAbhishekSah

Copy link
Copy Markdown
Member

What

resource.Update was DB-only and persisted just title/metadata. Moving a resource to a new project or reassigning its owner was therefore a silent no-op: the change was dropped from the row, and the old #project / #owner SpiceDB tuples stayed in place while the new ones were never written.

Fix

Update now:

  • persists project_id, principal_id, principal_type, and a recomputed URN (the URN embeds the project name). name and namespace stay immutable on update;
  • when the project changes, deletes the old app/<ns>:<id>#project tuple and writes the new one;
  • when the owner changes, deletes the old #owner tuple and writes the new one;
  • resolves PAT owners to the underlying user, mirroring Create.

Reconciliation is scoped to the #project / #owner relations — resource grant tuples (#granted rolebindings) are left untouched.

Test

New e2e regression test TestProjectResourceUpdateReconcile: create a resource in project A, move it to project B, then assert via ListRelations that the #project relation now points at B (old A tuple gone). Verified it fails without the reconcile (relation stays on A) and passes with it.

Addresses gap (7) of #1661.

@vercel

vercel Bot commented Jun 8, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Jun 9, 2026 6:31am

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 61b7ab48-20e7-4279-830c-4c3d1c70321a

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

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 and usage tips.

resource.Update was DB-only and persisted just title/metadata, so moving a
resource to a new project or reassigning its owner was a silent no-op: the
change was dropped from the row and the old #project/#owner SpiceDB tuples
stayed put while the new ones were never written.

Update now:
- persists project_id, principal_id, principal_type, and a recomputed URN
  (name and namespace remain immutable on update);
- when the project changes, deletes the old app/<ns>:<id>#project tuple and
  writes the new one;
- when the owner changes, deletes the old #owner tuple and writes the new one.

PAT owners are resolved to the underlying user, mirroring Create.

Adds an e2e regression test: create a resource in project A, move it to
project B, assert the #project relation now points at B (old tuple gone).
Verified it fails without the reconcile (relation stays on A) and passes
with it.

Refs #1661

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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