I encountered an issue while using the go-github library. When creating a GitHub Ruleset, I realized that two fields were inadvertently omitted from the request payload. As a result, the API call fails to create the ruleset.
Expected Behavior:
The github.Ruleset struct should include all the necessary fields to create a GitHub Ruleset, ensuring that no required fields are omitted, allow users to create ruleset successfully without encountering any errors.
Steps to Reproduce:
Both conditions.ref_name.include and conditions.ref_name.exclude fields are required even when empty.
curl -L -X POST "https://api.github.com/repos/ORG/REPO/rulesets" \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "content-type: application/json" \
-d '{
"name": "NAME",
"target": "branch",
"enforcement": "active",
"bypass_mode": "none",
"conditions": {
"ref_name": {
"include": ["refs/heads/main"]
}
},
"rules": []
}'
Cause response:
{
"message": "Validation Failed",
"errors": [
"Invalid target patterns: ''"
],
"documentation_url": "https://docs.github.com/rest/repos/rules#create-repository-ruleset"
}
Correct request
curl -L -X POST "https://api.github.com/repos/ORG/REPO/rulesets" \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "content-type: application/json" \
-d '{
"name": "NAME",
"target": "branch",
"enforcement": "active",
"bypass_mode": "none",
"conditions": {
"ref_name": {
"include": ["refs/heads/main"],
"exclude": []
}
},
"rules": []
}'
Additional Information:
- go-github library version: v53.1.1-0.20230617123624-6a57598c53ef (master)
I encountered an issue while using the go-github library. When creating a GitHub Ruleset, I realized that two fields were inadvertently omitted from the request payload. As a result, the API call fails to create the ruleset.
Expected Behavior:
The
github.Rulesetstruct should include all the necessary fields to create a GitHub Ruleset, ensuring that no required fields are omitted, allow users to create ruleset successfully without encountering any errors.Steps to Reproduce:
Both
conditions.ref_name.includeandconditions.ref_name.excludefields are required even when empty.Cause response:
{ "message": "Validation Failed", "errors": [ "Invalid target patterns: ''" ], "documentation_url": "https://docs.github.com/rest/repos/rules#create-repository-ruleset" }Correct request
Additional Information: