Skip to content

Conversation

@chemmi
Copy link

@chemmi chemmi commented May 15, 2025

The pattern can be confusing since Github API and UI differ in this point. This is just a clarification for the documentation.

See also: https://github.com/orgs/community/discussions/119797
See also: https://docs.github.com/en/rest/repos/rules#create-a-repository-ruleset

Resolves #ISSUE_NUMBER


Before the change?

  • Intuitively, the user would use the simple branch pattern main oder feat-* to include or exclude branches in the ruleset. The provider will crash with a 402 when applying the change:
Error: POST https://api.github.com/repos/ORG/REPO/rulesets: 422 Validation Failed [{Resource: Field: Code: Message:Invalid target patterns: 'main'}]

After the change?

  • The documentation suggests to use the required pattern, e.g. refs/heads/main, in this case.

See also the example in https://docs.github.com/en/rest/repos/rules#create-a-repository-ruleset which uses this pattern.

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

The pattern can be confusing since Github API and UI differ in this point.

See also: https://github.com/orgs/community/discussions/119797
@nickfloyd nickfloyd moved this from 🆕 Triage to 👀 In review in 🧰 Octokit Active Jun 3, 2025
@deiga
Copy link
Contributor

deiga commented Nov 28, 2025

Hey @chemmi 👋

I like your thinking here. The format is definitely confusing and we should help our users to not stumble on this.

I wonder if you'd be up for doing a few more modifications before this is good to merge?

  • Could you change the example from. refs/heads/main to maybe refs/heads/foo to make it distinct from ~DEFAULT_BRANCH?
  • I think the documentation could be improved here by adding this information into the field description as well. Could you add note to both description fields here about the expected format?
  • (optional) If you're feeling adventurous: Would you want to try to add validation to those fields? 😱

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants