Skip to content

Error when creating branch protection #2467

@luisdavim

Description

@luisdavim

Since we updated our code to use the latest version of this library, we can't create a branch protection that requires branches to be up to date before merging but don't require any status checks:

func (r *RepoSettings) protectionRequestOptions() *github.ProtectionRequest {
	return &github.ProtectionRequest{
		EnforceAdmins: r.EnforceAdmins,
		RequiredPullRequestReviews: &github.PullRequestReviewsEnforcementRequest{
			DismissStaleReviews:          r.DismissStaleReviews,
			RequiredApprovingReviewCount: r.RequiredApprovingReviewCount,
			RequireCodeOwnerReviews:      r.RequireCodeOwnerReviews,
		},
		RequiredStatusChecks: &github.RequiredStatusChecks{
			Strict: true,
		},
	}
}

The above results in an error:

PUT https://api.github.com/repos/****/****/branches/main/protection: 422 Invalid request.

No subschema in "anyOf" matched.
No subschema in "oneOf" matched.
Not all subschemas of "allOf" matched.
For 'anyOf/1', {"strict"=>true} is not a null. []

Such rule is possible to be created from the UI:
image

This is also affecting the Github Terraform provider: integrations/terraform-provider-github#1147

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions