Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP 422 when updating existing branch protection for CLA check #384

Open
kdmccormick opened this issue Jun 2, 2023 · 0 comments
Open

Comments

@kdmccormick
Copy link
Member

Just tried to run repo_checks.

openedx-tutor-plugins had no branch protection rule, and repo_checks added it no problem.

oars-dbt had a branch protection rule, but repo_checks failed to update it.

(venv) ~/openedx/repo-tools 🍀 repo_checks --no-dry-run
The following checks will be run:
	RequiredCLACheck
	RequireTriageTeamAccess
	RequireProductManagersAccess
	EnsureLabels
	EnsureWorkflowTemplates
openedx-tutor-plugins: 
	No branch protection rule. 'cla-checker' team not listed on the repo.
	Steps:
		Added new branch protection with `openedx/cla` as a required check.
		Added push access for cla-checker to openedx-tutor-plugins.
	'community-pr-triage-managers' team not listed on the repo.
	Steps:
		Added triage access for community-pr-triage-managers to openedx-tutor-plugins.
	'open-edx-product-managers' team not listed on the repo.
	Steps:
		Added triage access for open-edx-product-managers to openedx-tutor-plugins.
	All desired labels exist with the right name, color, description.
	Some workflows in this repo don't match the template.
		files_that_differ=[]
		files_that_are_missing=['self-assign-issue.yml', 'add-depr-ticket-to-depr-board.yml', 'commitlint.yml', 'add-remove-label-on-comment.yml']
	Steps:
		Branch does not exist. Creating 'repo_checks/ensure_workflows'.
		Updating workflow files on 'repo_checks/ensure_workflows'.
		Creating .github/workflows/self-assign-issue.yml
		Creating .github/workflows/add-depr-ticket-to-depr-board.yml
		Creating .github/workflows/commitlint.yml
		Creating .github/workflows/add-remove-label-on-comment.yml
		No PR exists, creating a PR.
		New PR: https://github.com/openedx/openedx-tutor-plugins/pull/2
oars-dbt: 
	CLA Check is not a required check. 'cla-checker' team has 'push' access.
State Before Update: {'branch': 'main',
 'enforce_admins': None,
 'owner': 'openedx',
 'repo': 'oars-dbt',
 'required_pull_request_reviews': {'dismiss_stale_reviews': (False,),
                                   'require_code_owner_reviews': (True,),
                                   'required_approving_review_count': (1,)},
 'required_status_checks': {'checks': [], 'strict': False},
 'restrictions': None}
Adding `openedx/cla` as a new required check to existing branch protection.
Update we're requesting: {'branch': 'main',
 'enforce_admins': None,
 'owner': 'openedx',
 'repo': 'oars-dbt',
 'required_pull_request_reviews': {'dismiss_stale_reviews': (False,),
                                   'require_code_owner_reviews': (True,),
                                   'required_approving_review_count': (1,)},
 'required_status_checks': {'checks': [{'app_id': -1,
                                        'context': 'openedx/cla'}],
                            'strict': False},
 'restrictions': None}
{'documentation_url': 'https://docs.github.com/rest/branches/branch-protection#update-branch-protection',
 'message': 'Invalid request.\n'
            '\n'
            'No subschema in "anyOf" matched.\n'
            "For 'properties/dismiss_stale_reviews', [false] is not a "
            'boolean.\n'
            "For 'properties/require_code_owner_reviews', [true] is not a "
            'boolean.\n'
            "For 'properties/required_approving_review_count', [1] is not an "
            'integer.\n'
            'Not all subschemas of "allOf" matched.\n'
            'For \'anyOf/1\', {"dismiss_stale_reviews"=>[false], '
            '"require_code_owner_reviews"=>[true], '
            '"required_approving_review_count"=>[1]} is not a null.'}
Traceback (most recent call last):
  File "/home/kyle/openedx/repo-tools/venv/bin/repo_checks", line 11, in <module>
    load_entry_point('edx-repo-tools', 'console_scripts', 'repo_checks')()
  File "/home/kyle/openedx/repo-tools/venv/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/kyle/openedx/repo-tools/venv/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/kyle/openedx/repo-tools/venv/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/kyle/openedx/repo-tools/venv/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/kyle/openedx/repo-tools/edx_repo_tools/repo_checks/repo_checks.py", line 1020, in main
    steps = check.fix()
  File "/home/kyle/openedx/repo-tools/edx_repo_tools/repo_checks/repo_checks.py", line 722, in fix
    steps += self._fix_branch_protection(dry_run)
  File "/home/kyle/openedx/repo-tools/edx_repo_tools/repo_checks/repo_checks.py", line 803, in _fix_branch_protection
    self._update_branch_protection(params)
  File "/home/kyle/openedx/repo-tools/edx_repo_tools/repo_checks/repo_checks.py", line 836, in _update_branch_protection
    resp.raise_for_status()
  File "/home/kyle/openedx/repo-tools/venv/lib/python3.8/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://api.github.com/repos/openedx/oars-dbt/branches/main/protection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To Do
Development

No branches or pull requests

1 participant