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

v2 Error: Expected a string but received a Array

Open thangleiter opened this issue 3 years ago • 2 comments

Today I experienced the same problem as https://github.com/codecov/codecov-action/issues/561, however, migrating from v1 to v2 did not help me. Instead, I get a new error with the uploader exiting with code 255:

[2021-10-25T17:54:04.067Z] ['verbose'] The error stack is: TypeError: Expected a string but received a Array
    at assertString (/snapshot/repo/node_modules/validator/lib/util/assertString.js:17:11)
    at Object.isAlphanumeric (/snapshot/repo/node_modules/validator/lib/isAlphanumeric.js:18:29)
    at validateToken (/snapshot/repo/dist/src/helpers/validate.js)
    at getToken (/snapshot/repo/dist/src/helpers/token.js)
    at main (/snapshot/repo/dist/src/index.js)
    at Object.<anonymous> (/snapshot/repo/dist/bin/codecov.js)
    at Module._compile (pkg/prelude/bootstrap.js:1794:22)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
[2021-10-25T17:54:04.067Z] ['verbose'] End of uploader: 13 milliseconds
Error: Codecov: Failed to properly upload: The process '/home/runner/work/_actions/codecov/codecov-action/v2/dist/codecov' failed with exit code 255

The codecov block in my yaml looks like this:

- name: Upload coverage to Codecov
  uses: codecov/codecov-action@v2
  with:
    file: ./coverage.xml
    name: ${{ matrix.python }} - ${{ matrix.install_extras }}
    env_vars: OS,PYTHON
    fail_ci_if_error: true
    verbose: true

thangleiter avatar Oct 25 '21 18:10 thangleiter

I have this error as well.

      uses: codecov/codecov-action@v2
      with:
        fail_ci_if_error: true
        file: ./coverage.xml
        flags: tests
        name: ${{ matrix.py }} - ${{ matrix.os }}
        verbose: true

BeyondEvil avatar Jan 17 '22 09:01 BeyondEvil

Any updates on this? v3 and master also fail while v1 works just fine.

thangleiter avatar Aug 30 '22 07:08 thangleiter

I have the same question when I use it by docker on windows. How to solve it.

leilin1995 avatar Mar 06 '23 07:03 leilin1995

I'm going to close this out as there isn't enough information to debug. My best guess is that one of the arguments being passed into name is an array and not a string. If you are still running into the issue, please open a topic in our community boards

thomasrockhu-codecov avatar Mar 10 '23 00:03 thomasrockhu-codecov

I also ran into this issue when using the CircleCI Codecov orb and invoking codecov/upload from a matrixed job. Same stack trace as well when in verbose mode.

I don't think the name is a factor, as the stack trace seems to imply that it failed the validation of the token.

I wonder if this is an issue with the use of matrices and the uploader? @thomasrockhu-codecov

danyim avatar Nov 07 '23 01:11 danyim