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

Consistent HTTP 422 errors when publishing assets to GitHub release #102

Closed
adrukh opened this issue Aug 22, 2018 · 7 comments
Closed

Consistent HTTP 422 errors when publishing assets to GitHub release #102

adrukh opened this issue Aug 22, 2018 · 7 comments
Assignees

Comments

@adrukh
Copy link

adrukh commented Aug 22, 2018

👋

We're using semantic-release/github plugin to publish assets to each release we make with semantic-release.

The release configuration is as follows:

{
  "prepare": [
    "@semantic-release/npm",
    {
      "path": "@semantic-release/exec",
      "cmd": "npm i -g pkg && pkg ."
    }
  ],
  "publish": [
    "@semantic-release/npm",
    {
      "path": "@semantic-release/github",
      "assets": [
        {
          "path": "./snyk-linux",
          "name": "snyk-linux",
          "label": "snyk-linux"
        },
        {
          "path": "./snyk-macos",
          "name": "snyk-macos",
          "label": "snyk-macos"
        },
        {
          "path": "./snyk-win.exe",
          "name": "snyk-win.exe",
          "label": "snyk-win.exe"
        }
      ]
    }
  ]
}

The assets are being published as expected, however the plugin fails over a 422 response from GH:

[06:49:06] [semantic-release] › ✖  An error occurred while running semantic-release: { HttpError: {"message":"Validation Failed","request_id":"AA68:095A:1D9FF3:201218:5B7D0761","documentation_url":"https://developer.github.com/v3","errors":[{"resource":"ReleaseAsset","code":"already_exists","field":"name"}]}
    at response.text.then.message (/home/travis/.nvm/versions/node/v8.11.4/lib/node_modules/semantic-release/node_modules/@octokit/rest/lib/request/request.js:72:19)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  name: 'HttpError',
  code: 422,
  status: undefined,
  headers: 
   { 'cache-control': 'no-cache',
     connection: 'close',
     'content-length': '211',
     'content-security-policy': 'default-src \'none\'',
     'content-type': 'application/json; charset=utf-8',
     date: 'Wed, 22 Aug 2018 06:49:06 GMT',
     'strict-transport-security': 'max-age=31557600',
     'x-accepted-oauth-scopes': 'repo',
     'x-content-type-options': 'nosniff',
     'x-frame-options': 'deny',
     'x-github-media-type': 'github.v3; format=json',
     'x-github-request-id': 'AA68:095A:1D9FF3:201218:5B7D0761',
     'x-oauth-scopes': 'repo',
     'x-xss-protection': '1; mode=block' },
  pluginName: '@semantic-release/github' }
{ HttpError: {"message":"Validation Failed","request_id":"AA68:095A:1D9FF3:201218:5B7D0761","documentation_url":"https://developer.github.com/v3","errors":[{"resource":"ReleaseAsset","code":"already_exists","field":"name"}]}
    at response.text.then.message (/home/travis/.nvm/versions/node/v8.11.4/lib/node_modules/semantic-release/node_modules/@octokit/rest/lib/request/request.js:72:19)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  name: 'HttpError',
  code: 422,
  status: undefined,
  headers: 
   { 'cache-control': 'no-cache',
     connection: 'close',
     'content-length': '211',
     'content-security-policy': 'default-src \'none\'',
     'content-type': 'application/json; charset=utf-8',
     date: 'Wed, 22 Aug 2018 06:49:06 GMT',
     'strict-transport-security': 'max-age=31557600',
     'x-accepted-oauth-scopes': 'repo',
     'x-content-type-options': 'nosniff',
     'x-frame-options': 'deny',
     'x-github-media-type': 'github.v3; format=json',
     'x-github-request-id': 'AA68:095A:1D9FF3:201218:5B7D0761',
     'x-oauth-scopes': 'repo',
     'x-xss-protection': '1; mode=block' },
  pluginName: '@semantic-release/github' }

More details at https://travis-ci.org/snyk/snyk/jobs/419030290

I appreciate the fact this may be on GH side, opened a support ticket with them, will update here once I hear back.

Wanted to document the issue here, maybe there's more context?

@pvdlg
Copy link
Member

pvdlg commented Aug 24, 2018

Can you run semantic-release with the --debug option? That would give you more information about what's going on.

@semantic-release-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 5.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@adrukh
Copy link
Author

adrukh commented Sep 7, 2018

THANKS for this fix! Sorry I missed your ask for --debug output, can confirm the issue is resolved for us!

@mirismaili
Copy link

mirismaili commented May 25, 2019

I also have this issue (semantic-release: v15.13.12). But the issue is not from semantic-release and its GitHub plugin. I think it's from GitHub itself (see this). This has been executed by github-release v0.7.2:

> github-release upload -u live-html-editor -r TextWrap -t v1.0.0 -l "3. Suitable for ..." -f dist/main.umd.js -s 8bf...771 -n main.umd.js

error: could not upload, status code (422 Unprocessable Entity), msg: Validation Failed, errors: [field: name, code: already_exists]

Similar to the error that I recived on the CI, previously:

script: npx semantic-release:

npx: installed 851 in 19.691s
[6:55:03 PM] [semantic-release] › ℹ  Running semantic-release version 15.13.12

...

[6:55:14 PM] [semantic-release] › ℹ  Start step "publish" of plugin "@semantic-release/github"
[6:55:15 PM] [semantic-release] [@semantic-release/github] › ℹ  Published GitHub release: https://github.com/live-html-editor/TextWrap/releases/tag/v1.0.0
[6:55:21 PM] [semantic-release] [@semantic-release/github] › ℹ  Published file https://github.com/live-html-editor/TextWrap/releases/download/v1.0.0/main.umd.js.map
[6:55:24 PM] [semantic-release] [@semantic-release/github] › ℹ  Published file https://github.com/live-html-editor/TextWrap/releases/download/v1.0.0/bundle.umd.js
[6:55:27 PM] [semantic-release] [@semantic-release/github] › ℹ  Published file https://github.com/live-html-editor/TextWrap/releases/download/v1.0.0/bundle.esm.js
[6:55:30 PM] [semantic-release] [@semantic-release/github] › ℹ  Published file https://github.com/live-html-editor/TextWrap/releases/download/v1.0.0/bundle.esm.js.map
[6:55:33 PM] [semantic-release] [@semantic-release/github] › ℹ  Published file https://github.com/live-html-editor/TextWrap/releases/download/v1.0.0/bundle.umd.js.map
[6:55:43 PM] [semantic-release] › ✖  Failed step "publish" of plugin "@semantic-release/github"
[6:55:43 PM] [semantic-release] › ✖  An error occurred while running semantic-release: { HttpError: Validation Failed
    at response.text.then.message (/home/travis/.npm/_npx/6593/lib/node_modules/semantic-release/node_modules/@octokit/request/dist-node/index.js:85:23)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  name: 'HttpError',
  status: 422,
  headers:
   { 'cache-control': 'no-cache',
     connection: 'close',
     'content-length': '211',
     'content-security-policy': 'default-src \'none\'',
     'content-type': 'application/json; charset=utf-8',
     date: 'Fri, 24 May 2019 18:55:43 GMT',
     'strict-transport-security': 'max-age=31557600',
     'x-accepted-oauth-scopes': 'repo',
     'x-content-type-options': 'nosniff',
     'x-frame-options': 'deny',
     'x-github-media-type': 'github.v3; format=json',
     'x-github-request-id': '9F8E:4CA7:1F037B:23CE1B:5CE83E2F',
     'x-oauth-scopes':
      'repo, read:org, user:email, repo_deployment, repo:status, write:repo_hook, write:packages, read:packages',
     'x-xss-protection': '1; mode=block' },
  request:
   { method: 'POST',
     url:
      'https://uploads.github.com/repos/live-html-editor/TextWrap/releases/17578568/assets?name=main.umd.js&label=3.%20Suitable%20for%20Node.js%20projects%20%28and%20any%20other%20UMD-compatible%20environment%20that%20can%20resolve%20dependencies%29.%20This%20is%20the%20one%20has%20been%20published%20on%20npm.js%20%28https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40live-html-editor%2Ftext-wrap%29%20and%20you%20can%20install%20it%20with%20%5Bnpm%20install%20...%5D.',
     headers:
      { accept: 'application/vnd.github.v3+json',
        'user-agent': 'octokit.js/16.27.0 Node.js/10.15.3 (Linux 4.15; x64)',
        'content-type': 'application/javascript',
        'content-length': 1632,
        authorization: 'token [REDACTED]' },
     body:
      <Buffer 21 66 75 6e 63 74 69 6f 6e 28 65 2c 74 29 7b 22 6f 62 6a 65 63 74 22 3d 3d 74 79 70 65 6f 66 20 65 78 70 6f 72 74 73 26 26 22 75 6e 64 65 66 69 6e 65 ... >,
     request:
      { agent: undefined,
        hook: [Function: bound bound register],
        validate: [Object] } },
  request_id: '9F8E:4CA7:1F037B:23CE1B:5CE83E2F',
  documentation_url: 'https://developer.github.com/v3',
  errors:
   [ { resource: 'ReleaseAsset',
       code: 'already_exists',
       field: 'name' } ],
  attemptNumber: 4,
  retriesLeft: 0,
  pluginName: '@semantic-release/github' }

@mirismaili
Copy link

My experience:

In the above case, the issue was from the label field (-l). I removed a part of it and it successfully was uploaded. I think the problem was from its length (that was too long ... 258 characters!).

@gr2m
Copy link
Member

gr2m commented May 25, 2019

If that’s the case, maybe try setup a minimal test repository to reproduce it and let https://github.com/support know? They’ll appreciate it. They sure could improve the error message

@juanpmarin
Copy link

@mirismaili did you workaround this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants