github-community-projects / github-community-projects/private-mirrors
Error when creating a ruleset isn't propagated to UI
- Dominant language
- TypeScript
- Stars
- 196
- Forks
- 41
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 4
Description
### Describe the bug
I created a private mirror on a test instance, and setting the branch protection ruleset failed because only GitHub Pro organizations can have rulesets on private repositories. But the error wasn't surfaced anywhere in the UI and I had to dig thru logs to find out what happened.
### To Reproduce
1. Set up a PMA instance on a free organization
2. Create a private mirror
3. Go to the mirror's settings and note there are no branch protections active
4. Check out the http log messages and search for a request to `https://api.github.com/repos/ORG-NAME/MIRROR-REPO-NAME/branches/main/protection, note the 403 returned (pasted below)
### Expected behavior
There should be an informational message on the UI that indicates a problem occured while creating the mirror
### Screenshots
_No response_
### Additional context
```json
{
"meta": {
"runtime": "Nodejs",
"runtimeVersion": "v22.5.1",
"hostname": "7eb1a3d020f1",
"name": "bot",
"date": "2024-09-27T05:38:34.488Z",
"logLevelId": 5,
"logLevelName": "ERROR",
"path": {
"fullFilePath": "/app/.next/server/pages/api/webhooks.js:146:5621",
"fileName": "webhooks.js",
"fileNameWithLine": "webhooks.js:146",
"fileColumn": "5621",
"fileLine": "146",
"filePath": "/.nex t/server/pages/api/webhooks.js",
"filePathWithLine": "/.next/server/pages/api/webhooks.js:146",
"method": "c"
}
},
"message": "Failed to create branch protection for default branch",
"data": {
"error": {
"name": "HttpError",
"statu s": 403,
"response": {
"url": "https://api.github.com/repos/ORGNAME/PRIVATE-MIRROR-NAME/branches/main/protection",
"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",
"content-encoding": "gzip",
"content-security-policy": "default-src 'none'",
"content-type": "application/json; charset=utf-8",
"date": "Fri, 27 Sep 2024 05:38:34 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": "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": "2A80:17D99D:F5B9ED:1CF4CBE:66F644D9",
"x-ratelimit-limit": "5000",
"x-ratelimit-remaining": "4989",
"x-ratelimit-reset": "1727419085",
"x-ratelimit-resource": "core",
"x-r atelimit-used": "11",
"x-xss-protection": "0"
},
"data": {
"message": "Upgrade to GitHub Pro or make this repository public to enable this feature.",
"documentation_url": "https://docs.github.com/rest/branches/branch-protection#update-branch-protection",
"status": "403"
}
},
"request": {
"method": "PUT",
"url": "https://api.github.com/repos/ORGNAME/PRIVATE-MIRROR-NAME/branches/main/protection",
"headers": {
"accept": "application/vnd.github.v3+json",
"user-agent": "probot/13.3.6 octokit-core.js/5.0.2 Node.js/22",
"x-github-delivery": "ba45f0f0-7c92-11ef-9833-a4f3eed6d2c0",
"authorization": "token [REDACTED]",
"content-type": "application/json; charset=utf-8"
}
}
}
}
}
"body":"{\ "enforce_admins\":true,\"required_pull_request_reviews\":{\"dismiss_stale_reviews\":true,\"require_code_owner_reviews\":false,\"required_approving_review_count\":1,\"dismissal_restrictions\":{\"users\":[],\"teams\":[ ]}},\"required_status_checks\":null,\"restrictions\":null}","request":{}
```
Contributor guide
Research direction
Start by tracing the webhook handling shown at pages/api/webhooks.js:146 and the mirror settings UI involved in creating branch protection. Reproduce the private-mirror setup and confirm the 403 path in the HTTP logs. Done means the branch-protection failure produces an informational message in the UI instead of remaining only in logs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github, typescript
- Domain
- api, full-stack
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100