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

Failure in adding one label prevents adding other labels and assigning participants #31091

Open
RahulGautamSingh opened this issue Aug 29, 2024 · 2 comments
Labels
platform:github GitHub Platform priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:bug Bug fix of existing functionality worker:pr Related to non-onboarding PR creation or update

Comments

@RahulGautamSingh
Copy link
Collaborator

RahulGautamSingh commented Aug 29, 2024

When labels could not be added/updated due to some issue. Other labels aren't added either. Plus, if this happens during PR creation, no assignees are assigned.

It logs a Pull Request creation error, but the pull request is created, only the labels and assignees are missing.

One such case is when labels cross the 50chars limit of Github labels.

Sample debug logs

Logs
DEBUG: PR created (branch="renovate/orange-cloudfoundry-k3s-packages-boshrelease-1.28.x")
{
  "baseBranch": "master"
  "pr": 100
  "draft": false
}

DEBUG: Adding labels 'datasource/github-tags, depName/orange-cloudfoundry/k3s-packages-boshrelease, hasReleaseNotes/true, manager/regex, orange-cloudfoundry/k3s-packages-boshrelease, type/bosh-release' to #100 (branch="renovate/orange-cloudfoundry-k3s-packages-boshrelease-1.28.x")
{
  "baseBranch": "master"
}

DEBUG: POST https://api.github.com/repos/orange-cloudfoundry/paas-templates-renovate-sample/issues/100/labels = (code=ERR_NON_2XX_3XX_RESPONSE, statusCode=422 retryCount=0, duration=160) (branch="renovate/orange-cloudfoundry-k3s-packages-boshrelease-1.28.x")
{
  "baseBranch": "master"
}

DEBUG: Received invalid response - aborting (branch="renovate/orange-cloudfoundry-k3s-packages-boshrelease-1.28.x")
{
  "baseBranch": "master"
  "err": {
    "name": "HTTPError",
    "code": "ERR_NON_2XX_3XX_RESPONSE",
    "timings": {
      "start": 1724847568824,
      "socket": 1724847568824,
      "lookup": 1724847568824,
      "connect": 1724847568824,
      "secureConnect": 1724847568824,
      "upload": 1724847568824,
      "response": 1724847568984,
      "end": 1724847568984,
      "phases": {
        "wait": 0,
        "dns": 0,
        "tcp": 0,
        "tls": 0,
        "request": 0,
        "firstByte": 160,
        "download": 0,
        "total": 160
      }
    },
    "message": "Response code 422 (Unprocessable Entity)",
    "stack": "HTTPError: Response code 422 (Unprocessable Entity)\n    at Request.<anonymous> (/usr/local/renovate/node_modules/.pnpm/[email protected]/node_modules/got/dist/source/as-promise/index.js:118:42)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)",
    "options": {
      "headers": {
        "user-agent": "RenovateBot/38.56.0 (https://github.com/renovatebot/renovate)",
        "accept": "application/json, application/vnd.github.machine-man-preview+json",
        "authorization": "***********",
        "content-type": "application/json",
        "content-length": "187",
        "accept-encoding": "gzip, deflate, br"
      },
      "url": "https://api.github.com/repos/orange-cloudfoundry/paas-templates-renovate-sample/issues/100/labels",
      "hostType": "github",
      "username": "",
      "password": "",
      "method": "POST",
      "http2": false
    },
    "response": {
      "statusCode": 422,
      "statusMessage": "Unprocessable Entity",
      "body": {
        "message": "Validation Failed",
        "errors": [
          {
            "value": "depName/orange-cloudfoundry/k3s-packages-boshrelease",
            "resource": "Label",
            "field": "name",
            "code": "invalid"
          }
        ],
        "documentation_url": "https://docs.github.com/rest/issues/labels#add-labels-to-an-issue",
        "status": "422"
      },
      "headers": {
        "date": "Wed, 28 Aug 2024 12:19:28 GMT",
        "content-type": "application/json; charset=utf-8",
        "content-length": "261",
        "x-github-media-type": "github.v3; param=machine-man-preview",
        "x-accepted-github-permissions": "issues=write; pull_requests=write",
        "x-github-api-version-selected": "2022-11-28",
        "x-ratelimit-limit": "6150",
        "x-ratelimit-remaining": "6141",
        "x-ratelimit-reset": "1724851073",
        "x-ratelimit-used": "9",
        "x-ratelimit-resource": "core",
        "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",
        "access-control-allow-origin": "*",
        "strict-transport-security": "max-age=31536000; includeSubdomains; preload",
        "x-frame-options": "deny",
        "x-content-type-options": "nosniff",
        "x-xss-protection": "0",
        "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
        "content-security-policy": "default-src 'none'",
        "vary": "Accept-Encoding, Accept, X-Requested-With",
        "x-github-request-id": "4067:284A20:38BCD7F:6D29735:66CF15D0",
        "server": "github.com"
      },
      "httpVersion": "1.1",
      "retryCount": 0
    }
  }
}

DEBUG: Pull request creation error (branch="renovate/orange-cloudfoundry-k3s-packages-boshrelease-1.28.x")
{
  "baseBranch": "master"
  "err": {
    "message": "repository-changed",
    "stack": "Error: repository-changed\n    at handleGotError (/usr/local/renovate/lib/util/http/github.ts:141:14)\n    at GithubHttp.request (/usr/local/renovate/lib/util/http/github.ts:380:13)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at GithubHttp.requestJson (/usr/local/renovate/lib/util/http/index.ts:291:17)\n    at addLabels (/usr/local/renovate/lib/modules/platform/github/index.ts:1494:5)\n    at Proxy.createPr (/usr/local/renovate/lib/modules/platform/github/index.ts:1764:3)\n    at ensurePr (/usr/local/renovate/lib/workers/repository/update/pr/index.ts:487:14)\n    at processBranch (/usr/local/renovate/lib/workers/repository/update/branch/index.ts:790:28)\n    at writeUpdates (/usr/local/renovate/lib/workers/repository/process/write.ts:166:17)\n    at update (/usr/local/renovate/lib/workers/repository/process/extract-update.ts:213:11)\n    at Object.renovateRepository (/usr/local/renovate/lib/workers/repository/index.ts:89:19)\n    at attributes.repository (/usr/local/renovate/lib/workers/global/index.ts:202:11)\n    at start (/usr/local/renovate/lib/workers/global/index.ts:187:7)\n    at /usr/local/renovate/lib/renovate.ts:18:22"
  }
}

Originally posted by @gberche-orange in #31080

@RahulGautamSingh RahulGautamSingh added priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:bug Bug fix of existing functionality worker:pr Related to non-onboarding PR creation or update platform:github GitHub Platform labels Aug 29, 2024
@RahulGautamSingh
Copy link
Collaborator Author

RahulGautamSingh commented Aug 29, 2024

  1. Its not possible to prevent failure in addition of all labels incase even one faces an issue because they are all added in a single api call. (this must be causing some issue with updating labels as well, need to debug to confirm)

  2. Adding a try-catch block there should prevent the issue with assigning assginees.

@rarkins
Copy link
Collaborator

rarkins commented Aug 29, 2024

There's three potential parts to this in order of importance:

  1. We should trim labels to 50 chars
  2. We should try/catch label addition so that assignee addition can continue even if labels fails
  3. If one label fails to validate retry with the remaining ones (if relevant)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:github GitHub Platform priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:bug Bug fix of existing functionality worker:pr Related to non-onboarding PR creation or update
Projects
None yet
Development

No branches or pull requests

2 participants