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

Safe Settings doesn't detect removed rules from repository rulesets

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

Description

## Problem Description
When one or more rules are manually removed from a ruleset or when required status checks are modified, Safe Settings doesn't detect any changes. Interestingly, it does detect changes when rules are added, ruleset name is changed or bypass actors are modified.
### What is actually happening
The app doesn't recognise changes when rules are removed from a repository ruleset.
### What is the expected behavior
If someone manually removes the rules the app should revert those changes and add the rules back in.
### Error output, if available

```
{"level":20,"time":1720003088766,"pid":25,"hostname":"safe-settings-app","name":"probot","name":"probot","name":"event","id":"54ec46e4-3928-11ef-944d-baa8cbbf33a3","msg":"Results of comparing Rulesets diffable target [{\"id\":1071805,\"name\":\"Custom-Bypass\",\"target\":\"branch\",\"source_type\":\"Repository\",\"source\":\"/test-data-product\",\"enforcement\":\"active\",\"conditions\":{\"ref_name\":{\"exclude\":[],\"include\":[\"~DEFAULT_BRANCH\"]}},\"rules\":[{\"type\":\"deletion\"}],\"node_id\":\"RRS_lACqUmVwb3NpdG9yec4ut6w-zgAQWr0\",\"created_at\":\"2024-07-01T15:18:56.620Z\",\"updated_at\":\"2024-07-01T15:18:56.620Z\",\"bypass_actors\":[],\"current_user_can_bypass\":\"never\",\"_links\":{\"self\":{\"href\":\"https://api.github.com/repos//test-data-product/rulesets/1071805\"},\"html\":{\"href\":\"https://github.com//test-data-product/rules/1071805\"}}}] with source [{\"name\":\"Custom-Bypass\",\"target\":\"branch\",\"enforcement\":\"active\",\"bypass_actors\":[],\"conditions\":{\"ref_name\":{\"include\":[\"~DEFAULT_BRANCH\"],\"exclude\":[]}},\"rules\":[{\"type\":\"non_fast_forward\"},{\"type\":\"deletion\"},{\"type\":\"required_linear_history\"},{\"type\":\"pull_request\",\"parameters\":{\"dismiss_stale_reviews_on_push\":true,\"require_code_owner_review\":true,\"require_last_push_approval\":true,\"required_approving_review_count\":1,\"required_review_thread_resolution\":true}},{\"type\":\"required_status_checks\",\"parameters\":{\"strict_required_status_checks_policy\":true,\"required_status_checks\":[{\"context\":\"run-lint\"}]}}]}] is [object Object]"}
{"level":20,"time":1720003088766,"pid":25,"hostname":"safe-settings-app","name":"probot","name":"probot","name":"event","id":"54ec46e4-3928-11ef-944d-baa8cbbf33a3","msg":"There are no changes for Rulesets for repo [object Object]. Skipping changes"}
```

## Context
Tried both on suborg and repo level
```
rulesets:
- name: Somename
target: branch
enforcement: active
conditions:
ref_name:
include: ["~DEFAULT_BRANCH"]
exclude: []
rules:
- type: non_fast_forward
- type: deletion
- type: required_linear_history
- type: pull_request
parameters:
dismiss_stale_reviews_on_push: true
require_code_owner_review: true
require_last_push_approval: true
required_approving_review_count: 1
required_review_thread_resolution: true
- type: required_status_checks
parameters:
strict_required_status_checks_policy: true
required_status_checks:
- context: run-lint
```
### Are you using the hosted instance of probot/settings or running your own?
Own deployment running v2.1.10
### If running your own instance, are you using it with github.com or GitHub Enterprise?
github.com
#### Version of probot/settings
2.1.10
#### Version of GitHub Enterprise
n/a

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.