Repository navigation
fix(rulesets): ignore omitted parameters that hold the GitHub default - #1103
lmbaschiera wants to merge 2 commits into
Conversation
When a ruleset is written without some rule parameters, GitHub fills them in: required_reviewers: [] and require_extra_approval_for_unattributed_changes: true on pull_request, and do_not_enforce_on_create: false on required_status_checks. compareDeep counts any parameter that is present in GitHub and missing from config as a deletion, so a config that never declared these reports changes on every sync and every ruleset with those rules is PUT each cycle. Skip the deletion only when GitHub's value equals that default. Omitting a parameter that GitHub holds at a different value is still a deletion, so removing real required_reviewers from config is still detected. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
d364a9a to
002df69
Compare
|
We hit the same thing upgrading to 3.0.0. Could you add dismissal_restriction: { enabled: false, allowed_actors: [] }Our NOP plan reports it as a deletion on number of |
…ault
GitHub fills in dismissal_restriction: { enabled: false,
allowed_actors: [] } on pull_request rules when config omits it,
reported on github-community-projects#1103 for 27 rules in another org. Add it to
PARAM_DELETION_DEFAULTS so that value is not planned as a deletion.
A restriction that is enabled or lists actors is still a deletion.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
I've added I couldn't verify the default on our side, though. None of our rulesets return |
Problem
When a ruleset is written without some rule parameters, GitHub fills them in and returns them on every GET:
pull_requestrequired_reviewers[]pull_requestrequire_extra_approval_for_unattributed_changestruerequired_status_checksdo_not_enforce_on_createfalsepull_requestdismissal_restriction{ enabled: false, allowed_actors: [] }dismissal_restrictionwas added at review: another 3.0.0 user saw GitHub fill it in on 27pull_requestrules. The orgs we observed don't return it.compareDeepcounts anyparameterskey that's present in GitHub and missing from config as a deletion; onlyallowed_merge_methodsis exempt, viaPARAM_DELETION_IGNORE. So a config that never declared these parameters reportsChanges foundon every sync, and every ruleset with apull_requestorrequired_status_checksrule is PUT on every cycle.We hit this upgrading to 3.0.0. A NOP full sync planned a PUT of every such org ruleset on every cycle, even though the PUT bodies matched the live rulesets apart from these defaults. The defaults were confirmed against rulesets that safe-settings itself had written without these keys: they read back with exactly the values above.
Fix
Skip the deletion only when GitHub's value equals the default (
PARAM_DELETION_DEFAULTS, compared with the existingstableStringify). Omitting a parameter that GitHub holds at a different value is still a deletion. That keeps the existingrequired_reviewersremoval detection intact (Ruleset Compare detects required_reviewers removal without bypass_actors churn), which is why these keys aren't simply added toPARAM_DELETION_IGNORE.Tests
Two new cases in
test/unit/lib/mergeDeep.test.js:pull_requestandrequired_status_checksrules carry the defaults, compared with a config that omits them, reports no changes. This fails before the fix.require_extra_approval_for_unattributed_changes: falseanddo_not_enforce_on_create: truein GitHub still reports both as deletions.npm run test:unitpasses (1006 tests), and the changed lines are clean undereslintandstandard.🤖 Generated with Claude Code