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

"Unable to locate build via Github Actions API" after switching to v2 action, v1 works fine #557

Closed
chris48s opened this issue Oct 13, 2021 · 21 comments · Fixed by cpp-linter/cpp-linter-hooks#20

Comments

@chris48s
Copy link

After receiving an email about the pending deprecation of the bash uploader, I decided to start migrating my repos to use the v2 uploader.

I tried switching one of my repos to the v2 (binary) uploader: chris48s/django-apiblueprint-view@c029bae

Unfortunately the upload is failing with the error:

['error'] Error POSTing to https://codecov.io: 404 {'detail': ErrorDetail(string='Unable to locate build via Github Actions API. Please upload with the Codecov repository upload token to resolve issue.', code='not_found')}
['error'] There was an error running the uploader: Error uploading to https://codecov.io: Error: Not Found

Full output:

Run codecov/codecov-action@v2
  with:
    file: ./coverage.xml
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.6.15/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.6.15/x64/lib
==> linux OS detected
https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
==> SHASUM file signed by key id 806bb28aed779869
==> Uploader SHASUM verified (d8fe17b4f8cf960b7b02a44067aab92681c7a983bdb9542c64624fc8281dfb80  codecov)
==> Running version latest
==> Running version v0.1.5
/home/runner/work/_actions/codecov/codecov-action/v2/dist/codecov -n  -Q github-action-2.1.0 -f ./coverage.xml
[2021-10-13T17:39:08.177Z] ['info'] 
     _____          _
    / ____|        | |
   | |     ___   __| | ___  ___ _____   __
   | |    / _ \ / _` |/ _ \/ __/ _ \ \ / /
   | |___| (_) | (_| |  __/ (_| (_) \ V /
    \_____\___/ \__,_|\___|\___\___/ \_/

  Codecov report uploader 0.1.5
[2021-10-13T17:39:08.184Z] ['info'] => Project root located at: /home/runner/work/django-apiblueprint-view/django-apiblueprint-view
[2021-10-13T17:39:08.185Z] ['info'] -> No token specified or token is empty
[2021-10-13T17:39:08.190Z] ['info'] Searching for coverage files...
[2021-10-13T17:39:08.203Z] ['info'] => Found 1 possible coverage files:
  ./coverage.xml
[2021-10-13T17:39:08.204Z] ['info'] Processing ./coverage.xml...
[2021-10-13T17:39:08.207Z] ['info'] Detected GitHub Actions as the CI provider.
[2021-10-13T17:39:08.208Z] ['info'] Pinging Codecov: https://codecov.io/upload/v4?package=github-action-2.1.0-uploader-0.1.5&token=*******&branch=master&build=1338587511&build_url=https%3A%2F%2Fgithub.com%2Fchris48s%2Fdjango-apiblueprint-view%2Factions%2Fruns%2F1338587511&commit=c029baeccc22fccdb28d7936bab2f135831fa65a&job=Run+tests&pr=&service=github-actions&slug=chris48s%2Fdjango-apiblueprint-view&name=&tag=&flags=&parent=
[2021-10-13T17:39:08.375Z] ['error'] Error POSTing to https://codecov.io: 404 {'detail': ErrorDetail(string='Unable to locate build via Github Actions API. Please upload with the Codecov repository upload token to resolve issue.', code='not_found')}
[2021-10-13T17:39:08.376Z] ['error'] There was an error running the uploader: Error uploading to https://codecov.io: Error: Not Found

As I understand the docs, public repos should still be able to upload coverage from GH actions without a token.
I switched the repo back to use the v1 (bash) uploader: chris48s/django-apiblueprint-view@77518ba and that fixes it.

Full output:

Run codecov/codecov-action@v1
  with:
    file: ./coverage.xml
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.6.15/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.6.15/x64/lib
/usr/bin/bash codecov.sh -n  -F  -Q github-action-v1.5.2 -f ./coverage.xml

  _____          _
 / ____|        | |
| |     ___   __| | ___  ___ _____   __
| |    / _ \ / _` |/ _ \/ __/ _ \ \ / /
| |___| (_) | (_| |  __/ (_| (_) \ V /
 \_____\___/ \__,_|\___|\___\___/ \_/
                              Bash-1.0.3


==> git version 2.33.0 found
==> curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
Release-Date: 2020-01-08
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets
==> GitHub Actions detected.
    Env vars used:
      -> GITHUB_ACTIONS:    true
      -> GITHUB_HEAD_REF:   
      -> GITHUB_REF:        refs/heads/master
      -> GITHUB_REPOSITORY: chris48s/django-apiblueprint-view
      -> GITHUB_RUN_ID:     1338646683
      -> GITHUB_SHA:        77518ba78fc6c558bf435093f7d0ad00fa880267
      -> GITHUB_WORKFLOW:   Run tests
    project root: .
    Yaml not found, that's ok! Learn more at http://docs.codecov.io/docs/codecov-yaml
    -> Found 1 reports
==> Detecting git/mercurial file structure
==> Reading reports
    + ./coverage.xml bytes=7556
==> Appending adjustments
    https://docs.codecov.io/docs/fixing-reports
    -> No adjustments found
==> Gzipping contents
        4.0K	/tmp/codecov.VO2yno.gz
==> Uploading reports
    url: https://codecov.io
    query: branch=master&commit=77518ba78fc6c558bf435093f7d0ad00fa880267&build=1338646683&build_url=http%3A%2F%2Fgithub.com%2Fchris48s%2Fdjango-apiblueprint-view%2Factions%2Fruns%2F1338646683&name=&tag=&slug=chris48s%2Fdjango-apiblueprint-view&service=github-actions&flags=&pr=&job=Run%20tests&cmd_args=n,F,Q,f
->  Pinging Codecov
https://codecov.io/upload/v4?package=github-action-v1.5.2-1.0.3&token=secret&branch=master&commit=77518ba78fc6c558bf435093f7d0ad00fa880267&build=1338646683&build_url=http%3A%2F%2Fgithub.com%2Fchris48s%2Fdjango-apiblueprint-view%2Factions%2Fruns%2F1338646683&name=&tag=&slug=chris48s%2Fdjango-apiblueprint-view&service=github-actions&flags=&pr=&job=Run%20tests&cmd_args=n,F,Q,f
->  Uploading to
https://storage.googleapis.com/codecov/v4/raw/2021-10-13/A8B82823B2FC04B2CBA76CF470EF5EC1/77518ba78fc6c558bf435093f7d0ad00fa880267/c57660b7-23a7-4944-be89-a8854e75f288.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GOOG1EKKHVKCKHW7KBCGM7IHR55T63V2PAVJWLVFNITJHDU5G6R5IRN3LMWJA%2F20211013%2FUS%2Fs3%2Faws4_request&X-Amz-Date=20211013T175743Z&X-Amz-Expires=10&X-Amz-SignedHeaders=host&X-Amz-Signature=217f3b2e8acbf722d7fd2b58c9dfadc262cd2dc42920f327d266e44ca1d89237
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  1240    0     0  100  1240      0   7337 --:--:-- --:--:-- --:--:--  7337
    -> Reports have been successfully queued for processing at https://codecov.io/github/chris48s/django-apiblueprint-view/commit/77518ba78fc6c558bf435093f7d0ad00fa880267
@tomvothecoder
Copy link

tomvothecoder commented Oct 13, 2021

@chris48s
Copy link
Author

Ah thanks for the links 👍 I checked for other issues on this repo to see if anyone else had already reported this but I did not know to check on https://github.com/codecov/uploader

@ktdreyer
Copy link

I'm also seeing this error with v1.

@nhatthm
Copy link

nhatthm commented Oct 13, 2021

I think it's fixed. I just retriggered the jobs and all good now

Update: it's flapping

Update 2: Back again

Update 3: Down again

Update 4: Back. It smells like a rate limiter issue

@tomvothecoder
Copy link

This issue looks like it is resolved after codecov/uploader#426 was merged and https://github.com/codecov/uploader/releases/tag/v0.1.6 was released.

@chris48s
Copy link
Author

Can confirm this is now resolved - thanks 👍

@ssbarnea
Copy link

I am not sure to which extent this was fixed because lately I seen more and more random errors like this. https://github.com/ansible-community/ansible-lint/runs/5625894991?check_suite_focus=true

@jab
Copy link

jab commented Mar 23, 2022

Same here. Should this issue be reopened as long as this is still affecting users?

@ssbarnea
Copy link

TBH, this proved to be a major cause of build failures and the solution would be to make the action itself have an implicit retry logic with delay, maybe even with 5min.

99% of failures are transient and retries would succeed, so I hope they will do the right think and implement that, especially as it is impossible for the consumers to do the same, due to the limitation of workflows.

@LucaMarconato
Copy link

LucaMarconato commented Aug 9, 2022

In my case I was getting the same error, and I managed to fix it thanks to #295.

The error was

 ['error'] Error POSTing to https://codecov.io: 404 {'detail': ErrorDetail(string='Unable to locate build via Github Actions API. Please upload with the Codecov repository upload token to resolve issue.', code='not_found')}

when running codecov via act, while I didn't have problems when running codecov via GitHub Actions. The reason is that you need to pass the codecov token to act. This is not required for public repos as explained in the codecov website (settings panel of any repository):

Note: Token not required for public repositories uploading from Travis, CircleCI, AppVeyor, Azure Pipelines or GitHub Actions

The solution was to run act with the additional argument --env CODECOV_TOKEN=xxx, where xxx is the token that you can find from the codecov website.

@ssbarnea
Copy link

During the last 2-3 days I observed a huge spike in number of failed uploads due to 404 error and I checked neither Github nor Codecov reported any outages while this was happening.

This is really failing our jobs and if the upload has real changes of failure, we should have an implicit retry mechanism embedded in the upload logic, so we avoid breaking these.

['error'] There was an error running the uploader: Error uploading to [https://codecov.io:](https://codecov.io/) Error: There was an error fetching the storage URL during POST: 404 - {'detail': ErrorDetail(string='Unable to locate build via Github Actions API. Please upload with the Codecov repository upload token to resolve issue.', code='not_found')}
[79](https://github.com/ansible/ansible-lint/runs/7859542166?check_suite_focus=true#step:13:80)
[2022-08-16T14:03:22.405Z] ['verbose'] The error stack is: Error: Error uploading to [https://codecov.io:](https://codecov.io/) Error: There was an error fetching the storage URL during POST: 404 - {'detail': ErrorDetail(string='Unable to locate build via Github Actions API. Please upload with the Codecov repository upload token to resolve issue.', code='not_found')}
[80](https://github.com/ansible/ansible-lint/runs/7859542166?check_suite_focus=true#step:13:81)
    at main (/snapshot/repo/dist/src/index.js)
[81](https://github.com/ansible/ansible-lint/runs/7859542166?check_suite_focus=true#step:13:82)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

@drazisil-codecov
Copy link
Contributor

@ssbarnea ,

The issue here is for tokenless uploads to work, we need to use our API token instead of yours. Given how many public repos we support, we hit our rate limit with GitHub fairly often. We have been in discussions on how to handle this, but a retry would not have helped and only made things worse in this case, as I believe that GitHub will extend the delay if you keep making the same request after they tell you no.

Sorry, that's not an ideal answer.

@ssbarnea
Copy link

In fact is is a good answer. The problem was that the error message does not mention this limitation and the docs are clear: "if is public you do not need a custom token". Fix these two places and we will know what to do. Just mention that rate limiting for public can produce this error and users will know what to do.

I will start adding the tokens, is not really a bit issue, is just that that is the first time when I know why to docs is misleading. THANKS!

@TomaszZieleskiewicz
Copy link

Using token from your "Let's get your repo covered" site seems to solve this issue (even is it is bolded there that no token is needed for public repos).
So mentioning that on this site would help a lot. :)

@ssbarnea
Copy link

@TomaszZieleskiewicz @drazisil-codecov Apparently we still face random 404 error even after adding CODECOV_TOKEN to repository secrets on a public repository. Example: https://github.com/ansible/ansible-lint/runs/7965627356?check_suite_focus=true

The fact that thing problem was not addressed in years drives will drive people out of codecov. Is not that it was not known, it is just that it was never considered important enough. Why we do not have at least two retries with a delay of 1 or more minutes in between?

It would be acceptable if the failure rate would like 0.1%, but if the failure rate is 2%, that translates to 22% for a pipeline that has 10 uploads, because 1.02^10 ~ 1.22, and that is only due to failure to upload coverage.

I think that the only thing that I can do now is to reconfigure the pipelines to ignore failures of this step. It is dangerous but likely less damaging than getting broken builds due to coverage.

I would not have posted this long comment if it was just yet another random upload failure, it is more than that.

By reading comments from #598, I am wondering if the repository secret might not be available to pull requests coming from forks. Is that true is not really clear which is the right way to reconfigure the jobs.

No wonder that we might get frustrated about a case where docs mention token is not needed for public repos, but in fact it is needed for practical use, but it might not work for some pull requests even when given,...

@TomaszZieleskiewicz
Copy link

@ssbarnea, what have helped me, and what I thought you suggested was adding token not only to secrets, but to CI yaml as well. Like that:

    - name: Code coverage
      uses: codecov/codecov-action@v3
      with:
        token: ${{ secrets.CODECOV_TOKEN }}

Have you tried it?

ssbarnea added a commit to ansible/ansible-lint that referenced this issue Aug 24, 2022
@ssbarnea
Copy link

I seen something very weird in my verbose logs from the pull request, "no token was used or the token was empty", the change that was adding the line you mentioned. I now updated the token from repository secrets but I doubt it was really empty.

Somehow I suspect that github does not pass the repository secrets for pull requests from forks, as a security measure. Still that token is a weak secret and it is absolutely needed to see the coverage for incoming pull request, probably more important than even measuring it on main branch.

wzieba added a commit to Parsely/parsely-android that referenced this issue Nov 3, 2023
Although open source projects don't require upload with token, CodeCov
default token meets limits sometimes, resulting in failed uploads. See
more details here:
codecov/codecov-action#557 (comment).

The solution is to use our own Codecov token.
shenxianpeng added a commit to cpp-linter/cpp-linter-hooks that referenced this issue Jan 11, 2024
shenxianpeng added a commit to cpp-linter/cpp-linter-hooks that referenced this issue Jan 11, 2024
alexbarcelo added a commit to code-specialist/fastapi-keycloak that referenced this issue Jan 17, 2024
MartinAkram pushed a commit to Parsely/parsely-android that referenced this issue Jan 17, 2024
Although open source projects don't require upload with token, CodeCov
default token meets limits sometimes, resulting in failed uploads. See
more details here:
codecov/codecov-action#557 (comment).

The solution is to use our own Codecov token.
rwestphal added a commit to holo-routing/holo that referenced this issue Apr 8, 2024
Reference: codecov/codecov-action#557

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
oSoMoN added a commit to oSoMoN/uutils-diffutils that referenced this issue Apr 16, 2024
rwestphal added a commit to holo-routing/yang-rs that referenced this issue Apr 27, 2024
Reference: codecov/codecov-action#557

Also, set `fail_ci_if_error` to `false` to prevent the CI from failing
in case the Codecov servers are unstable or down.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Farhad-Shabani pushed a commit to cosmos/ibc-rs that referenced this issue Sep 9, 2024
* Don't fail CI if unable to upload to codecov

* Use our own codecov token to avoid rate-limiting

See codecov/codecov-action#557 (comment)
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

Successfully merging a pull request may close this issue.