Skip to content

Precedence order not working as expected for arrays in branch policy #722

@riprasad

Description

@riprasad

Problem Description

As per the README - The precedence order for settings file is repository > suborg > org (.github/repos/.yml > .github/suborgs/.yml > .github/settings.yml

However, when defining branch policies at both the suborganization and repository levels, policies that require array inputs are merged rather than being overridden.

What is actually happening

suborg/default.bpr.yml

suborgrepos:
  - '*'
  
branches:
  - name: default
    protection:
        required_pull_request_reviews: null
        required_status_checks: null
        enforce_admins: false
        restrictions:
            apps: ['app-01', 'app-02']
            users: ['user-01']
            teams: []

repos/repo.yml


branches:
  - name: default
    protection:
        required_pull_request_reviews: null
        required_status_checks: null
        enforce_admins: true
        restrictions:
            apps: ['app-03']
            users: ['user-02']
            teams: []

Properties with boolean or string input types are functioning as expected, and the values defined in the repo.yml file are being correctly applied. However, properties with array input types are being merged instead of being overridden.

For instance, the restriction being applied is:

        restrictions:
            apps: ['app-01', 'app-02', 'app-03']
            users: ['user-01', 'user-02']
            teams: []

What is the expected behavior

Only the apps and users defined in the repo.yml should be applied, while the apps and users defined the sub-org level should be ignored.

        restrictions:
            apps: ['app-03']
            users: ['user-02']
            teams: []

Error output, if available

NA

Context

Are you using the hosted instance of probot/settings or running your own?

Running Safe Settings via Github Actions

If running your own instance, are you using it with github.com or GitHub Enterprise?

github.com

Version of probot/settings

2.1.14

Version of GitHub Enterprise

NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions