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

Could not add github status: 404 Not Found #93

Open
kumar303 opened this issue Aug 9, 2017 · 14 comments
Open

Could not add github status: 404 Not Found #93

kumar303 opened this issue Aug 9, 2017 · 14 comments

Comments

@kumar303
Copy link

kumar303 commented Aug 9, 2017

I'm trying to use bundlesize without github integration. Is that possible? In other words, I haven't added a token but I thought I could still use the output to tell me if my bundle has reached the threshold or not.

I set up my TravisCI to run bundlesize in my build step. This worked fine in a branch but when I merged it to master it failed every time like this:

$ bundlesize
 ERROR  Could not add github status.
        404: Not Found 

error Command failed with exit code 1.

Here is an example of a failure: https://travis-ci.org/mozilla/addons-frontend/builds/262798345?utm_source=github_status&utm_medium=notification

@siddharthkp
Copy link
Owner

Ah, that's a bug

I'll take care of that!

@jorgebucaran
Copy link

@siddharthkp Is this fixed?

@siddharthkp
Copy link
Owner

No 😢

Haven't been able to make time for this. Would you like to take a shot at it?

@jorgebucaran
Copy link

@siddharthkp BTW I was getting the same error locally. 🤔
Where does one start looking?

jorgebucaran pushed a commit to jorgebucaran/hyperapp that referenced this issue Aug 21, 2017
- Bundlesize was fun to use, but after updating to their latest
  I've been unable to make it work as normal because of:

    siddharthkp/bundlesize/issues/93

  I could downgrade and wait for them to fix the bug, but I've
  decided to remove it from the project on the basis that we
  have  no dependencies and it's extremely unlikely the bundle
  size will suddenly increase without anyone noticing.
@karanjthakkar
Copy link
Contributor

@jbucaran I'm sorry you had to remove the integration because it was unusable.

const handleError = error => {
is where the error is thrown and https://github.com/siddharthkp/github-build/blob/bdc53116ccf94cf6d2294fe1607aadca6bfdc26e/index.js#L9 is where it actually comes from.

It seems like a good idea to run in some kindda CI_ONLY mode if GITHUB_TOKEN isn't available. Just to understand a bit more exactly what you need, are you saying you would like to manually check the CI logs to tell you that the bundlesizes have crossed the limit? Or would you want bundlesize to exit with a non-zero error code to signify that the build broke?

@jorgebucaran
Copy link

jorgebucaran commented Aug 27, 2017

Hey @karanjthakkar. I actually removed bundlesize because it wasn't really so useful in that particular project, but I'd definitely use this or a similar tool on a project with a lot of dependencies or where the code changes a lot.

Just to understand a bit more exactly what you need, are you saying you would like to manually check the CI logs to tell you that the bundlesizes have crossed the limit?

I used to have this in my pkgjson.

"test": "bundlesize && npm run test"

And bundlesize would exit with a non-zero error code preventing "npm run test" to execute. Last time I checked, "npm run test" wouldn't even run and I was getting an error resembling (unfortunately I can't remember exactly what):

ERROR  Could not add github status.
  404: Not Found  

@siddharthkp
Copy link
Owner

siddharthkp commented Aug 27, 2017

@jbucaran @karanjthakkar Ooh, a couple of interesting things here.

  1. If you want your tests to continue running, you can make that bundlesize || npm run test, but then bundlesize would not be able to fail your builds!

    Alternatively, you can split them into different commands and let your CI configuration decide whether it wants to fail early or run all the tests (I know travis CI supports this, don't know about the rest, sorry!)

  2. Could not add github status can happen in a few cases:

    a) This is an enterprise repo (bundlesize doesn't support enterprise yet, open issue here: Add support for Github Enterprise github-build#3)

    b) You have given a wrong github token and setting the status failed. Github API returns a 404 in such cases (bundlesize should handle this better)

    c) You are not giving a github token, but bundlesize didn't know that and tried to set values for master anyways and failed. Potential bug on this line: reporter.js#L80, can be fixed by adding if (api.enabled)

jorgebucaran added a commit to jorgebucaran/hyperapp that referenced this issue Jan 7, 2018
- Bundlesize was fun to use, but after updating to their latest
  I've been unable to make it work as normal because of:

    siddharthkp/bundlesize/issues/93

  I could downgrade and wait for them to fix the bug, but I've
  decided to remove it from the project on the basis that we
  have  no dependencies and it's extremely unlikely the bundle
  size will suddenly increase without anyone noticing.
@Raigen
Copy link

Raigen commented Jan 30, 2018

For me this is an issue because I have a GITHUB_TOKEN in my local environment, but only for some automated gists. Naturally that token does not have access to any repos. And it should not because when I run builds locally I do not want bundlesize to do anything with my github token. But I still would like to know if something I did accidently raised the size of the bundle before I push it to the pull-request and CI tells me.

Is it important that bundlesize looks for the GITHUB_TOKEN variable? Because it is often used by tools in development environments. E.g. by some vim plugins.

@siddharthkp
Copy link
Owner

@Raigen, as far as I remember, you can run it on local without giving a token and it should work. (correct me if this isn't happening in your case)

@Raigen
Copy link

Raigen commented Jan 31, 2018

@siddharthkp I already use a token for some gist things, but bundlesize tries to use it and then fails the build because of a 404 from github because the token is meant for gist only.
An option/cli parameter would be nice to opt-in github status feature in CI and do nothing locally even when there is a token. Or an opt-out for locale machines to not break existing integrations.

@siddharthkp
Copy link
Owner

My view here is that it should just ignore tokens on non-ci env

Can you open a different issue for this?

@vigneshshanmugam
Copy link

I opened a PR that will fix the issue on running bundlesize on NON CI environments #291

@aleclarson
Copy link

aleclarson commented Aug 27, 2019

I'm facing the same error. Using the --debug flag, it seems that the request to bundlesize-store.now.sh is hitting an internal server error.

$ GITHUB_REPOSITORY="alloc/wana" GITHUB_SHA="master" BUNDLESIZE_GITHUB_TOKEN="[redacted]" ./node_modules/.bin/bundlesize -f "dist/index.js" --debug

 WARN  cli config: [
  {
    "path": "dist/index.js",
    "compression": "gzip"
  }
] 

 WARN  file config: undefined 

 WARN  selected config: [
  {
    "path": "dist/index.js",
    "compression": "gzip"
  }
] 

 WARN  files: [
  {
    "maxSize": null,
    "path": "dist/index.js",
    "size": 4877,
    "compression": "gzip"
  }
] 

 WARN  token exists: true 

 WARN  repo: undefined 

 WARN  sha: undefined 

 WARN  api enabled: false 

 PASS  dist/index.js: 4.76KB (gzip) 

 WARN  message: "dist/index.js: 4.76KB (gzip)" 

 WARN  url before shortening: "https://bundlesize-store.now.sh/build?info=%7B%22files%22%3A%5B%7B%22maxSize%22%3Anull%2C%22path%22%3A%22dist%2Findex.js%22%2C%22size%22%3A4877%2C%22compression%22%3A%22gzip%22%7D%5D%7D" 

 WARN  err while shortening: {
  "message": "Request failed with status code 403",
  "name": "Error",
  "stack": "Error: Request failed with status code 403\n    at createError (/dev/wana/node_modules/.registry.npmjs.org/axios/0.19.0/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/dev/wana/node_modules/.registry.npmjs.org/axios/0.19.0/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/dev/wana/node_modules/.registry.npmjs.org/axios/0.19.0/node_modules/axios/lib/adapters/http.js:237:11)\n    at IncomingMessage.emit (events.js:202:15)\n    at endReadableNT (_stream_readable.js:1129:12)\n    at processTicksAndRejections (internal/process/next_tick.js:76:17)",
  "config": {
    "url": "https://www.googleapis.com/urlshortener/v1/url?key=AIzaSyACIqikanS3eoHsy14JYyFAHU1aU5w1YoA",
    "method": "post",
    "data": "{\"longUrl\":\"https://bundlesize-store.now.sh/build?info=%7B%22files%22%3A%5B%7B%22maxSize%22%3Anull%2C%22path%22%3A%22dist%2Findex.js%22%2C%22size%22%3A4877%2C%22compression%22%3A%22gzip%22%7D%5D%7D\"}",
    "headers": {
      "Accept": "application/json, text/plain, */*",
      "Content-Type": "application/json;charset=utf-8",
      "User-Agent": "axios/0.19.0",
      "Content-Length": 199
    },
    "transformRequest": [
      null
    ],
    "transformResponse": [
      null
    ],
    "timeout": 0,
    "xsrfCookieName": "XSRF-TOKEN",
    "xsrfHeaderName": "X-XSRF-TOKEN",
    "maxContentLength": -1
  }
} 

 WARN  global message: "dist/index.js: 4.76KB (gzip)" 

 ERROR  Could not add github status.
        404: Not Found 

@JoshMcCullough
Copy link

Temp. fix is to clear the env var before running your build e.g.: GITHUB_TOKEN='' npm publish

alexbbt added a commit to alexbbt/bundlesize that referenced this issue Mar 11, 2020
This was causing an error with generic CI tokens, this should only use a project specific token, closes siddharthkp#93
chief825 added a commit to chief825/hyperapp that referenced this issue Mar 31, 2022
- Bundlesize was fun to use, but after updating to their latest
  I've been unable to make it work as normal because of:

    siddharthkp/bundlesize/issues/93

  I could downgrade and wait for them to fix the bug, but I've
  decided to remove it from the project on the basis that we
  have  no dependencies and it's extremely unlikely the bundle
  size will suddenly increase without anyone noticing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants