bundlesize icon indicating copy to clipboard operation
bundlesize copied to clipboard

Sudden 404: Not Found error

Open denkristoffer opened this issue 7 years ago • 13 comments

Do you want to request a feature or report a bug? Bug

What is the current behavior? Bundlesize returns "Could not add github status. 404: Not Found"

Please mention other relevant information. We've been using bundlesize with Circle CI for months with no issues, but during the night between the 18th and the 19th of September something has broken. We're now getting the above error. I've tried updating and replacing the token ENV var to no avail.

denkristoffer avatar Sep 19 '18 09:09 denkristoffer

The usual suspects are:

  • https://bundlesize-store.now.sh is down (it isn't)
  • your GitHub token expired (you replaced it)
  • your new token does not have access to add status (?)
  • bundlesize hit rate limit for GitHub (i don't think it has enough users yet :P)

GitHub error messages usually give a 404 instead of 401 in cases like this

I'd suggest checking if the token has access, and running bundlesize with --debug flag to see if spots one of the common problems

siddharthkp avatar Sep 19 '18 14:09 siddharthkp

Running bundlesize with --debug gives me output ending with the following (after displaying all the chunk sizes:

 WARN  token exists: true 

 WARN  repo: "Onlaw/onlaw.dk" 

 WARN  sha: "f1c43040e6b8ad10122bfb7a22a4b44a2d10d958" 

 WARN  api enabled: true 

 WARN  fetching values: "..." 

 ERROR  Could not add github status.
        404: Not Found 

Doesn't tell me much. Any ideas?

denkristoffer avatar Sep 20 '18 07:09 denkristoffer

I have the exact same issue as @denkristoffer, any ideas @siddharthkp ? Using CircleCI.

Regarding

your new token does not have access to add status (?)

How do I check it? @siddharthkp

When I tried to generate the token, although I am being asked my GitHub credentials, I do not see another intermediate screen until https://bundlesize-store.now.sh/auth?code=XYZ site

cihati avatar Nov 26 '18 20:11 cihati

I'm having the same problem. I've done a bit of digging - I've run bundlesize locally with:

BUNDLESIZE_GITHUB_TOKEN=<my token> CI=true yarn bundlesize --debug

and I've added a line to node_modules/github-build/index.js to log the raw Github response:

{ response:
   { status: 404,
     statusText: 'Not Found',
     headers: {
        'x-ratelimit-limit': '5000',
        'x-ratelimit-remaining': '4953',
        'x-oauth-scopes': 'repo:status',
        'x-accepted-oauth-scopes': '',
        ...
     config: {
        method: 'POST',
        url:
         'https://api.github.com/repos/<my org>/<my repo>/statuses/<commit sha>',
        responseType: 'json',
        data:
         '{"state":"pending","target_url":"<dummy URL>","description":"Checking output size...","context":"bundlesize"}' },
        ...
     data:
      { message: 'Not Found',
        documentation_url:
         'https://developer.github.com/v3/repos/statuses/#create-a-status' } } }


 ERROR  Could not add github status.
        404: Not Found

I've checked the token's scope:

❯ curl -H "Authorization: token <my token>" https://api.github.com/repos/<my org>/<my repo>/statuses/<commit sha> -I
HTTP/1.1 404 Not Found
X-OAuth-Scopes: repo:status
X-Accepted-OAuth-Scopes: repo, repo:status

❯ curl -X POST -H "Authorization: token <my token>" https://api.github.com/repos/<my org>/<my repo>/statuses/<commit sha> -I
HTTP/1.1 404 Not Found
X-OAuth-Scopes: repo:status
X-Accepted-OAuth-Scopes:

Does anyone know if this means that the token doesn't have permission to update the status?

alexlouden avatar Jan 18 '19 10:01 alexlouden

Does anyone know if this means that the token doesn't have permission to update the status?

Yep, GitHub sends down a 404 if you don't have permission

siddharthkp avatar Jan 18 '19 10:01 siddharthkp

Yep, GitHub sends down a 404 if you don't have permission

Thanks for the reply! I've authorised the bundlesize Github app, and I've tried selecting "All repositories" and just one repo, and I get the 404 either way. Anything else I can try or any other ideas?

alexlouden avatar Jan 18 '19 10:01 alexlouden

It's difficult to debug from afar 😅

You might to run with the --debug just to make sure the tokens are read.

siddharthkp avatar Jan 18 '19 11:01 siddharthkp

Same here with Circle CI

landvibe avatar May 19 '19 10:05 landvibe

I figured out the problem last week! I discovered the bundlesize app (at https://github.com/settings/applications) wasn't granted organisation access to the org the repo was in. Once I granted it access the error went away 🤦‍♂ 😀

alexlouden avatar May 20 '19 10:05 alexlouden

@siddharthkp I don't think this issue should be closed, missing access was never the problem in my case.

denkristoffer avatar May 21 '19 06:05 denkristoffer

Oops, sorry. There was another sub-thread in between.

siddharthkp avatar May 22 '19 07:05 siddharthkp

I just fixed this on our pipeline. The BUNDLESIZE_GITHUB_TOKEN can expire. Github will reply with a 404. Follow the steps here to reset your token: https://github.com/siddharthkp/bundlesize#build-status-for-github

  1. go here: https://github.com/login/oauth/authorize?scope=repo%3Astatus&client_id=6756cb03a8d6528aca5a
  2. replace the token in your build tool with the supplied token.
  3. restart build.

grumpyoldman-io avatar Oct 31 '19 09:10 grumpyoldman-io

What is the lifetime of this token? A token can not just expire without being automatically refreshed when this is supposed to be embedded into corporate CI workflows.

PaulKujawa avatar Jan 22 '20 09:01 PaulKujawa