Renovate: Hosted Renovate Bot does not update any branches, because it receives 422, when setting "stability-days" status

Created on 4 Sep 2020  路  18Comments  路  Source: renovatebot/renovate

What Renovate type, platform and version are you using?

Hosted Renovate on app.renovatebot.com + Github connection.

Describe the bug

It won't create PR's, or update them, auto merge them most of the time, because it encounters a 422, while trying to set the stability day status.

Relevant debug logs

}
DEBUG: Updating renovate/stability-days status check state to green(branch="renovate/definitelytyped")
DEBUG: Setting branch status(branch="renovate/definitelytyped")
{
  "context": "renovate/stability-days",
  "state": "green"
}
DEBUG: 422 Error thrown from GitHub(branch="renovate/definitelytyped")
{
  "err": {
    "name": "HTTPError",
    "timings": {
      "start": 1599206906787,
      "socket": 1599206906787,
      "lookup": 1599206906787,
      "connect": 1599206906858,
      "secureConnect": 1599206906932,
      "upload": 1599206906933,
      "response": 1599206907267,
      "end": 1599206907268,
      "phases": {
        "wait": 0,
        "dns": 0,
        "tcp": 71,
        "tls": 74,
        "request": 1,
        "firstByte": 334,
        "download": 1,
        "total": 481
      }
    },
    "body": {
      "message": "Validation Failed",
      "errors": [
        {
          "resource": "Status",
          "code": "custom",
          "field": "sha",
          "message": "sha must be a 40 character SHA1"
        }
      ],
      "documentation_url": "https://docs.github.com/rest/reference/repos#create-a-commit-status"
    },
    "message": "Response code 422 (Unprocessable Entity)",
    "stack": "HTTPError: Response code 422 (Unprocessable Entity)\n    at onResponse (/home/ubuntu/renovateapp/node_modules/renovate/node_modules/got/dist/source/as-promise/index.js:142:28)\n    at runMicrotasks ()\n    at processTicksAndRejections (internal/process/task_queues.js:97:5)"
  }
}

copied from the app.renovatebot.com log output.

To Reproduce

I created a minimal repository, that has that problem: https://github.com/homefully/renovate-bug

Additional context

(My Assumptions!)
It seems like there is a bug in how the github api is used, which causes a 422, which intern gets bubbled up and turned into "repository-changed", which isn't true, it just happens that the bug caused a very similar response code from github.
But having not looked into the renovate code at all, I can only assume that from the logs above.

github priority-2-important bug

Most helpful comment

This will be put into the hosted app later today

All 18 comments

@rarkins Looks like we don't get the branchCommit because no checkout was done?

https://github.com/renovatebot/renovate/blob/6a0fade7f90daf9861e04f02649ee8a4ca64ed92/lib/platform/github/index.ts#L946-L961

Is it for a new branch (not on github.com yet) or an existing one? getBranchCommit shouldn't need any checkout

Yes, possible we don't update our cache after a force push? But I don't see that specific detail in the reproduction steps, which implies it happens non stop?

@rarkins It happens non-stop, (in the reproduction repository, it never even made it to the pull-request stage. The branch is created, but it fails setting the status on that and aborts)

They do exist on github.com in the branches view (https://github.com/homefully/renovate-bug/branches)

We noticed, that sometimes the bot manages to update the branches and pr's correctly. Then in all works as intended, and it even manages to auto-merge some branches.
But I have no Idea why it sometimes does work, and at other times it doesn't.

I'm suffering from the same issue, GitHub returns sha must be a 40 character SHA1 validation error:

DEBUG: 422 Error thrown from GitHub(branch="renovate/io.grpc-grpc-bom-1.x") { "err": { "name": "HTTPError", "timings": { "start": 1599725600412, "socket": 1599725600412, "lookup": 1599725600414, "connect": 1599725600427, "secureConnect": 1599725600440, "upload": 1599725600440, "response": 1599725600648, "end": 1599725600648, "phases": { "wait": 0, "dns": 2, "tcp": 13, "tls": 13, "request": 0, "firstByte": 208, "download": 0, "total": 236 } }, "message": "Response code 422 (Unprocessable Entity)", "stack": "HTTPError: Response code 422 (Unprocessable Entity)\n at Request. (/home/ubuntu/renovateapp/node_modules/renovate/node_modules/got/dist/source/as-promise/index.js:117:42)\n at runMicrotasks ()\n at processTicksAndRejections (internal/process/task_queues.js:97:5)", "options": { "headers": { "user-agent": "Renovate Bot (GitHub App 2740)", "accept-encoding": "gzip, deflate", "accept": "application/vnd.github.machine-man-preview+json", "authorization": "***********", "content-type": "application/json", "content-length": "164" }, "url": "https://api.github.com/repos/remal/tracing-spec/statuses/6cf9b52", "username": "", "password": "***********", "method": "POST", "http2": false }, "response": { "statusCode": 422, "statusMessage": "Unprocessable Entity", "body": { "message": "Validation Failed", "errors": [ { "resource": "Status", "code": "custom", "field": "sha", "message": "sha must be a 40 character SHA1" } ], "documentation_url": "https://docs.github.com/rest/reference/repos#create-a-commit-status" }, "headers": { "date": "Thu, 10 Sep 2020 08:13:20 GMT", "content-type": "application/json; charset=utf-8", "content-length": "228", "connection": "close", "server": "GitHub.com", "status": "422 Unprocessable Entity", "x-github-media-type": "github.v3; param=machine-man-preview; format=json", "x-ratelimit-limit": "5000", "x-ratelimit-remaining": "4996", "x-ratelimit-reset": "1599729029", "x-ratelimit-used": "4", "access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, 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": "1; mode=block", "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": "C74A:3804:AD5F95:D66E2E:5F59E020" } } } }

@rarkins looks like we somehow only get the short commit sha. So this seems to be the root cause of this problem.

I think we need to check why we only get a short sha.

Maybe we can detect this type of problem if we stringly type shortCommitSha and longCommitSha and pass them around instead of variable length string?

I think I have a fix for this, will push soon

yes, it's because git commit only dumps the short sha, so we should fetch the full sha after commit.

git rev-parse HEAD should print our current commit

:tada: This issue has been resolved in version 23.20.6 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

This will be put into the hosted app later today

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OmgImAlexis picture OmgImAlexis  路  4Comments

Flydiverny picture Flydiverny  路  4Comments

Arcanemagus picture Arcanemagus  路  4Comments

hutson picture hutson  路  3Comments

ikatyang picture ikatyang  路  4Comments