github-community-projects / github-community-projects/safe-settings

Rulesets using `{{EXTERNALLY_DEFINED}}` report "Update Ruleset" in every dry run

Open Beginner friendly
#1,022 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
921
Forks
226
Avg merge
18h 3m
Merged PRs (30d)
14

Description

A ruleset that uses `{{EXTERNALLY_DEFINED}}` in `required_status_checks` (support added by #741) shows up as "Update Ruleset" in every dry-run/PR check, even when nothing differs from what's on GitHub.

The cause is an ordering problem in `lib/plugins/rulesets.js`: `changed()` runs `mergeDeep.compareDeep(existing, attrs)` on the raw config, where `attrs` still contains the literal `{{EXTERNALLY_DEFINED}}` string. `Overrides.removeOverrides` (which swaps the placeholder for the live GitHub value) is only called inside `update()` and `add()`, after the comparison already decided there's a change — and in nop mode the `update()` early-return means it's never called at all. The literal placeholder never equals the real status checks, so `hasChanges` is always true.

Two consequences:

- Every plan and PR comment shows a phantom "Update Ruleset" for these rulesets, which drowns out real changes.
- In apply mode, safe-settings issues a PUT on every sync for these rulesets, writing the same values back.

The branches plugin doesn't have this problem because it resolves overrides *inside* its comparison (`branches.js`, the `compareDeep` call passes the config through `Overrides.removeOverrides` first). The rulesets plugin needs the same treatment.

Contributor guide

Open the contributing guide

Research direction

Start in lib/plugins/rulesets.js and compare its changed() logic with the compareDeep call in branches.js. Resolve {{EXTERNALLY_DEFINED}} before comparison so dry runs and apply-mode syncs do not report or perform updates when values match; verify the ruleset plan and PR output no longer show phantom changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
devops
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.