Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when creating a ruleset isn't propagated to UI #241

Open
ahpook opened this issue Sep 27, 2024 · 0 comments
Open

Error when creating a ruleset isn't propagated to UI #241

ahpook opened this issue Sep 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ahpook
Copy link
Contributor

ahpook commented Sep 27, 2024

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

{
  "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":{}
@ahpook ahpook added the bug Something isn't working label Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant