codecov-node icon indicating copy to clipboard operation
codecov-node copied to clipboard

TypeError: Cannot read property 'startsWith' of undefined

Open FezVrasta opened this issue 4 years ago • 13 comments

Hi, we run Codecov with npx codecov --token=${CODECOV_TOKEN} and starting from last week we started seeing these sporadic errors:

==> Building file structure
==> Generating gcov reports (skip via --disable=gcov)
    $ find /home/circleci/repo/frontend -type f -name '*.gcno'  -exec gcov  {} +
    Failed to run gcov command.
==> Scanning for reports
    + /home/circleci/repo/frontend/coverage/clover.xml
    + /home/circleci/repo/frontend/coverage/lcov.info
==> Uploading reports
/home/circleci/.npm/_npx/56c18755c3006eff/node_modules/teeny-request/build/src/agents.js:30
    var isHttp = uri.startsWith('http://');
                     ^

TypeError: Cannot read property 'startsWith' of undefined
    at Object.getAgent (/home/circleci/.npm/_npx/56c18755c3006eff/node_modules/teeny-request/build/src/agents.js:30:22)
    at requestToFetchOptions (/home/circleci/.npm/_npx/56c18755c3006eff/node_modules/teeny-request/build/src/index.js:86:30)
    at teenyRequest (/home/circleci/.npm/_npx/56c18755c3006eff/node_modules/teeny-request/build/src/index.js:143:14)
    at /home/circleci/.npm/_npx/56c18755c3006eff/node_modules/codecov/lib/codecov.js:213:9
    at /home/circleci/.npm/_npx/56c18755c3006eff/node_modules/teeny-request/build/src/index.js:233:13
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
npm ERR! code 1
npm ERR! path /home/circleci/repo/frontend
npm ERR! command failed
npm ERR! command sh -c codecov "--token="

Running the CI build again usually fixes it, are you aware of the issue?

FezVrasta avatar Feb 25 '21 16:02 FezVrasta

@FezVrasta I think we were having some issues server-side that had us not returning a proper uri. Are you still experiencing this issue?

To be clear, we should fix the uploader to be more transparent of the error as opposed to what you saw here, but I wanted to make sure you weren't blocked.

thomasrockhu avatar Mar 02 '21 00:03 thomasrockhu

I still experienced this problem yesterday. I'll keep it monitored today. Thanks!

FezVrasta avatar Mar 02 '21 06:03 FezVrasta

I'm seeing the same error with the same stack trace now... How can we workaround this?

tsuz avatar Mar 02 '21 08:03 tsuz

I can confirm I'm still seeing these errors.

FezVrasta avatar Mar 03 '21 11:03 FezVrasta

Considered Codecov doesn't seem to be interested in fixing this issue I suppose for now I'll go with npx retry-cli -n 3 -- npx codecov --token=${CODECOV_TOKEN} but we'll likely get rid of codecov all together at some point.

FezVrasta avatar Mar 10 '21 14:03 FezVrasta

I am running in to this as well. To be honest the Codecov sign up / Github connection / setup process leaves a lot to be desired.

fishactual avatar Mar 14 '21 08:03 fishactual

Update, we had to remove it because the retry trick didn't work

FezVrasta avatar Mar 14 '21 11:03 FezVrasta

This can be worked around by using bash version of codecov so that

codecov -f ./coverage/coverage-final.json

becomes

bash <(curl -s https://codecov.io/bash) -f ./coverage/coverage-final.json

hope this helps.

tsuz avatar Mar 22 '21 13:03 tsuz

Having the same issue. If, maybe, they're still investigating the issue, at least a workaround from codecov would be nice.

pbassut avatar Apr 25 '21 02:04 pbassut

I had the same problem with codecov nodemodule and decided to dig deeper into the code. The problem in my case is that the token which I am using is invalid. I detected the root problem by logging the result in this code https://github.com/codecov/codecov-node/blob/master/lib/codecov.js#L215. In my case, the root error is: {'detail': ErrorDetail(string='Could not find a repository associated with upload token <MY_INVALID_TOKEN>', code='not_found')} even though the error message from codecov is misleading. Hopefully this tip helps troubleshooting your problems as well.

anhnguyen1618 avatar Apr 28 '21 13:04 anhnguyen1618

Also happens in the following circumstances:

  • a private repository on GitHub
  • Codecov GitHub application configured with public access

Then 100% of the time I get Cannot read property 'startsWith' of undefined. I would expect a better error message like Cannot find where to update coverage, or even please give access to codecov application or use a codecov token.

dmail avatar May 21 '21 16:05 dmail

I’m seeing this for external GitLab merge requests (for example appsemble/appsemble!1917), but not for internal ones.

remcohaszing avatar Jun 07 '21 10:06 remcohaszing

I released 3.8.3 which should help with this issue

thomasrockhu avatar Jul 19 '21 18:07 thomasrockhu