github-community-projects / github-community-projects/safe-settings
Rulesets cannot be set for all repos when the org does not have an enterprise subscription
- Dominant language
- JavaScript
- Stars
- 921
- Forks
- 226
- Avg merge
- 18h 3m
- Merged PRs (30d)
- 14
Description
## Problem Description
When the GitHub organization does not have an enterprise subscription, it is not possible to set rulesets for all repos in the organization.
### What is actually happening
What happens is that safe-settings queries `https://api.github.com/orgs//rulesets` and the API returns a 403 with a message that reads: `Upgrade to GitHub Enterprise to enable this feature.`. This prevents the use of safe-settings to apply rulesets to all individual repos in the org.
### What is the expected behavior
It is expected that safe-settings should allow a user to set a ruleset for all repos in an organization by controlling rulesets on all repos in the org instead of via the org-level rulesets.
### Error output, if available
```
|
-- | --
{"level":50,"time":1699959656065,"pid":26,"hostname":"safe-settings-demo-99cb5dcf8-hwg58","name":"probot","name":"probot","name":"event","id":"13bc6ffc-82dd-11ee-92eb-11a42222cbb3","name":"HttpError","status":403,"response":{"url":"https://api.github.com/orgs/[REDACTED]/rulesets","status":403,"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag,
Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit,
X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource,
X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes,
X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id,
Deprecation,
Sunset","connection":"close","content-encoding":"gzip","content-security-policy":"default-src
'none'","content-type":"application/json; charset=utf-8","date":"Tue,
14 Nov 2023 11:00:56 GMT","referrer-policy":"origin-when-cross-origin,
strict-origin-when-cross-origin","server":"GitHub.com","strict-transport-security":"max-age=31536000;
includeSubdomains;
preload","transfer-encoding":"chunked","vary":"Accept-Encoding, Accept,
X-Requested-With","x-accepted-github-permissions":"organization_administration=write","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-api-version-selected":"2022-11-28","x-github-media-type":"github.v3;
format=json","x-github-request-id":"B62A:3EA2:4C2CA2:9E0057:65535367","x-ratelimit-limit":"5000","x-ratelimit-remaining":"4899","x-ratelimit-reset":"1699962859","x-ratelimit-resource":"core","x-ratelimit-used":"101","x-xss-protection":"0"},"data":{"message":"Upgrade
to GitHub Enterprise to enable this
feature.","documentation_url":"https://docs.github.com/rest/orgs/rules#create-an-organization-repository-ruleset"}},"request":{"method":"POST","url":"https://api.github.com/orgs/[REDACTED]/rulesets","headers":{"accept":"application/vnd.github.v3+json","user-agent":"probot/12.3.1
octokit-core.js/3.6.0 Node.js/16.20.2 (linux;
x64)","x-github-api-version":"2022-11-28","authorization":"token
[REDACTED]","content-type":"application/json;
charset=utf-8"},"body":"{\"name\":\"Enforce pull
requests\",\"target\":\"branch\",\"enforcement\":\"active\",\"conditions\":{\"ref_name\":{\"include\":[\"~DEFAULT_BRANCH\"],\"exclude\":[\"refs/heads/oldmaster\"]},\"repository_name\":{\"include\":[\"[REDACTED]\"],\"exclude\":[\"test\",\"test1\"],\"protected\":true}},\"rules\":[{\"type\":\"pull_request\",\"parameters\":{\"dismiss_stale_reviews_on_push\":true,\"require_code_owner_review\":true,\"require_last_push_approval\":true,\"required_approving_review_count\":1,\"required_review_thread_resolution\":true}}]}","request":{"retryCount":1}},"stack":"HttpError:
Upgrade to GitHub Enterprise to enable this feature.\n at
/opt/safe-settings/node_modules/probot/node_modules/@octokit/request/dist-node/index.js:86:21\n
at runMicrotasks (<anonymous>)\n at
processTicksAndRejections (node:internal/process/task_queues:96:5)\n
at async sendRequestWithRetries
(/opt/safe-settings/node_modules/octokit-auth-probot/node_modules/@octokit/auth-app/dist-node/index.js:398:12)\n
at async Job.doExecute
(/opt/safe-settings/node_modules/bottleneck/light.js:405:18)","type":"Error","msg":"Upgrade
to GitHub Enterprise to enable this feature."}
```
## Context
This may well be the intended behavior and if so, it would be good to make this clear in the documentation.
### Are you using the hosted instance of probot/settings or running your own?
Self-hosting
### If running your own instance, are you using it with github.com or GitHub Enterprise?
github.com
#### Version of probot/settings
Probot v12.3.1 (Node.js: v16.20.2)
#### Version of GitHub Enterprise
N/A
Contributor guide
Assessment
This issue has not been assessed yet.