Skip to content

fix(rbac): preserve stored conditions when conditional reconcile fails#9691

Open
PatAKnight wants to merge 4 commits into
backstage:mainfrom
PatAKnight:conditional-policies-bug
Open

fix(rbac): preserve stored conditions when conditional reconcile fails#9691
PatAKnight wants to merge 4 commits into
backstage:mainfrom
PatAKnight:conditional-policies-bug

Conversation

@PatAKnight

@PatAKnight PatAKnight commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Hey, I just made a Pull Request!

Conditional policy reload used remove-then-add ordering, so when adds failed (e.g. Catalog permission metadata 503), stored conditions were already deleted.

Reconciliation now stages and persists all additions before any removals. On add-phase failure, stored conditions are preserved and a batch abort is logged/audited via abortConditionalPolicyReconcile in helper.ts.

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

@backstage-goalie

Copy link
Copy Markdown
Contributor

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage-community/plugin-rbac-backend workspaces/rbac/plugins/rbac-backend patch v7.14.0

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to prevent loss of stored conditional RBAC policies when a conditional reconcile/reload fails (e.g., due to permission metadata lookup failures), by staging additions and only applying removals after additions succeed, plus adding batch-abort auditing/logging.

Changes:

  • Reworked conditional policy reconciliation to “add first, then remove” and added a batch-abort audit/log helper.
  • Added new helper utilities (diffConditionalPolicies, abortConditionalPolicyReconcile) with unit tests.
  • Updated provider and YAML watcher test suites and added a changeset entry.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
workspaces/rbac/plugins/rbac-backend/src/providers/connect-providers.ts Changes conditional reconcile flow; adds abort auditing and diffing helper usage.
workspaces/rbac/plugins/rbac-backend/src/providers/connect-providers.test.ts Adds regression test for “preserve on add failure” and updates audit expectations.
workspaces/rbac/plugins/rbac-backend/src/helper.ts Introduces diff + reconcile-abort helper and logging/auditing behavior.
workspaces/rbac/plugins/rbac-backend/src/helper.test.ts Adds unit tests for new helper utilities.
workspaces/rbac/plugins/rbac-backend/src/file-permissions/yaml-conditional-file-watcher.ts Changes YAML reload flow to stage additions before removals and adds abort auditing.
workspaces/rbac/plugins/rbac-backend/src/file-permissions/yaml-conditional-file-watcher.test.ts Updates expectations and adds regression test for metadata-unavailable reload.
workspaces/rbac/.changeset/beige-timers-marry.md Patch changeset describing the behavioral change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread workspaces/rbac/plugins/rbac-backend/src/providers/connect-providers.ts Outdated
Comment thread workspaces/rbac/plugins/rbac-backend/src/helper.ts
Assisted-by: Cursor AI
Signed-off-by: Patrick Knight <pknight@redhat.com>
…e conflicts

Assisted-by: Cursor AI
Signed-off-by: Patrick Knight <pknight@redhat.com>
…l reconcile failures

Assisted-by: Cursor AI
Signed-off-by: Patrick Knight <pknight@redhat.com>
Assisted-by: Cursor AI
Signed-off-by: Patrick Knight <pknight@redhat.com>
@PatAKnight PatAKnight force-pushed the conditional-policies-bug branch from d2c294f to c0f34b8 Compare June 24, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants