codecov-action: `Token required - not valid tokenless upload` when token is provided

Upon upgrade to codecov/codecov-action@v5 from codecov/codecov-action@v4, the action begins to fail, citing Token required - not valid tokenless upload.

This appears to occur as a result of the branch that results in message Fork detected, tokenless uploading used.

Relevant workflow snippet:

      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@v5
        with:
          files: ${{ env.COVERAGE_FILE_NAME }}
          flags: ${{ matrix.test_directory }}
          fail_ci_if_error: true
          token: ${{ secrets.CODECOV_TOKEN }}

GH action logs:

Run codecov/codecov-action@v5
  with:
    files: coverage-unit-e4561b105e68283540953b58188f445a168a8585.xml
    flags: unit
    fail_ci_if_error: true
    token: ***
  
    disable_file_fixes: false
    disable_search: false
    disable_safe_directory: false
    dry_run: false
    git_service: github
    gcov_executable: gcov
    handle_no_reports_found: false
    skip_validation: false
    use_legacy_upload_endpoint: false
    use_oidc: false
    verbose: false
    version: latest
  env:
    ENV: test
    COVERAGE_FILE_NAME: coverage-unit-e4561b105e68283540953b58188f445a168a8585.xml
    pythonLocation: /opt/hostedtoolcache/Python/3.9.20/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.20/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.20/x64/lib
Run git config --global --add safe.directory /home/runner/work/emrapi/emrapi
  git config --global --add safe.directory /home/runner/work/emrapi/emrapi
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    ENV: test
    COVERAGE_FILE_NAME: coverage-unit-e4561b105e68283540953b58188f445a168a8585.xml
    pythonLocation: /opt/hostedtoolcache/Python/3.9.20/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.20/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.20/x64/lib
Run if [ false == 'true' ];
  if [ false == 'true' ];
  then
    # {"count":1984,"value":"***"}
    CC_TOKEN=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange" | cut -d\' -f6)
    echo "CC_TOKEN=$CC_TOKEN" >> "$GITHUB_ENV"
  else
    if [ -n ***
   ];
    then
      CC_TOKEN=***
  
      echo "CC_TOKEN=$CC_TOKEN" >> "$GITHUB_ENV"
    fi
  fi
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    ENV: test
    COVERAGE_FILE_NAME: coverage-unit-e4561b105e68283540953b58188f445a168a8585.xml
    pythonLocation: /opt/hostedtoolcache/Python/3.9.20/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.20/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.20/x64/lib
/home/runner/work/_temp/1707b567-cb5d-4c55-a48c-bded8ca40a72.sh: line 7: [: missing `]'
/home/runner/work/_temp/1707b567-cb5d-4c55-a48c-bded8ca40a72.sh: line 8: ]: command not found
Run if [ -z "$CC_BRANCH" ] && [ -z "$CC_TOKEN" ] && [ "${GITHUB_EVENT_PULL_REQUEST_REPO_FULL_NAME}" != "$GITHUB_REPOSITORY" ];
  if [ -z "$CC_BRANCH" ] && [ -z "$CC_TOKEN" ] && [ "${GITHUB_EVENT_PULL_REQUEST_REPO_FULL_NAME}" != "$GITHUB_REPOSITORY" ];
  then
    echo -e "\033[0;32m==>\033[0m Fork detected, tokenless uploading used"
    TOKENLESS="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL"
    CC_BRANCH="$GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL"
    echo "TOKENLESS=$TOKENLESS" >> "$GITHUB_ENV"
  fi
  
  echo "CC_BRANCH=$CC_BRANCH" >> "$GITHUB_ENV"
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    ENV: test
    COVERAGE_FILE_NAME: coverage-unit-e4561b105e68283540953b58188f445a168a8585.xml
    pythonLocation: /opt/hostedtoolcache/Python/3.9.20/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.20/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.20/x64/lib
    CC_BRANCH: 
    GITHUB_EVENT_PULL_REQUEST_HEAD_LABEL: 
    GITHUB_EVENT_PULL_REQUEST_REPO_FULL_NAME: 
    GITHUB_REPOSITORY: VillageMD/emrapi
==> Fork detected, tokenless uploading used
Run if [ -z "$CC_SHA" ];
  if [ -z "$CC_SHA" ];
  then
    CC_SHA="$GITHUB_EVENT_PULL_REQUEST_HEAD_SHA"
  fi
  if [ -z "$CC_PR" ] && [ "${GITHUB_EVENT_NAME}" == "pull_request_target" ];
  then
    CC_PR="$GITHUB_EVENT_NUMBER"
  fi
  
  echo "CC_SHA=$CC_SHA" >> "$GITHUB_ENV"
  echo "CC_PR=$CC_PR" >> "$GITHUB_ENV"
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    ENV: test
    COVERAGE_FILE_NAME: coverage-unit-e4561b105e68283540953b58188f445a168a8585.xml
    pythonLocation: /opt/hostedtoolcache/Python/3.9.20/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.20/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.20/x64/lib
    TOKENLESS: 
    CC_BRANCH: 
    CC_PR: 
    CC_SHA: 
    GITHUB_EVENT_NAME: push
    GITHUB_EVENT_NUMBER: 
    GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: 
Run ${GITHUB_ACTION_PATH}/dist/codecov.sh
  ${GITHUB_ACTION_PATH}/dist/codecov.sh
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    ENV: test
    COVERAGE_FILE_NAME: coverage-unit-e4561b105e68283540953b58188f445a168a8585.xml
    pythonLocation: /opt/hostedtoolcache/Python/3.9.20/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.20/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.20/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.20/x64/lib
    TOKENLESS: 
    CC_BRANCH: 
    CC_SHA: 
    CC_PR: 
    CC_BINARY: 
    CC_BUILD: 
    CC_BUILD_URL: 
    CC_CODE: 
    CC_DIR: 
    CC_DISABLE_FILE_FIXES: false
    CC_DISABLE_SEARCH: false
    CC_DRY_RUN: false
    CC_ENTERPRISE_URL: 
    CC_ENV: 
    CC_EXCLUDES: 
    CC_FAIL_ON_ERROR: true
    CC_FILES: coverage-unit-e4561b105e68283540953b58188f445a168a8585.xml
    CC_FLAGS: unit
    CC_GCOV_ARGS: 
    CC_GCOV_EXECUTABLE: gcov
    CC_GCOV_IGNORE: 
    CC_GCOV_INCLUDE: 
    CC_GIT_SERVICE: github
    CC_HANDLE_NO_REPORTS_FOUND: false
    CC_JOB_CODE: 
    CC_LEGACY: false
    CC_NAME: 
    CC_NETWORK_FILTER: 
    CC_NETWORK_PREFIX: 
    CC_NETWORK_ROOT_FOLDER: 
    CC_OS: 
    CC_PARENT_SHA: 
    CC_PLUGINS: 
    CC_REPORT_TYPE: 
    CC_SKIP_VALIDATION: false
    CC_SLUG: 
    CC_SWIFT_PROJECT: 
    CC_VERBOSE: false
    CC_VERSION: latest
    CC_YML_PATH: 
     _____          _
    / ____|        | |
   | |     ___   __| | ___  ___ _____   __
   | |    / _ \ / _` |/ _ \/ __/ _ \ \ / /
   | |___| (_) | (_| |  __/ (_| (_) \ V /
    \_____\___/ \__,_|\___|\___\___/ \_/
                            Wrapper-0.0.24
                                  
==> Detected linux
 -> Downloading https://cli.codecov.io/latest/linux/codecov
==> Finishing downloading linux:latest
      Version: v9.0.4
 
gpg: directory '/home/runner/.gnupg' created
gpg: keybox '/home/runner/.gnupg/pubring.kbx' created
gpg: /home/runner/.gnupg/trustdb.gpg: trustdb created
gpg: key 806BB28AED779869: public key "Codecov Uploader (Codecov Uploader Verification Key) <security@codecov.io>" imported
gpg: Total number processed: 1
gpg:               imported: 1
==> Verifying GPG signature integrity
 -> Downloading https://cli.codecov.io/latest/linux/codecov.SHA256SUM
 -> Downloading https://cli.codecov.io/latest/linux/codecov.SHA256SUM.sig
 
gpg: Signature made Fri Nov 15 18:59:14 2024 UTC
gpg:                using RSA key 27034E7FDB850E0BBC2C62FF806BB28AED779869
gpg: Good signature from "Codecov Uploader (Codecov Uploader Verification Key) <security@codecov.io>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 2703 4E7F DB85 0E0B BC2C  62FF 806B B28A ED77 9869
codecov: OK
==> CLI integrity verified

 -> Token of length 0 detected
==> Running create-commit
      ./codecov  create-commit --fail-on-error --git-service github
info - 2024-11-19 13:52:41,549 -- ci service found: github-actions
info - 2024-11-19 13:52:41,769 -- Process Commit creating complete
error - 2024-11-19 13:52:41,770 -- Commit creating failed: {"message":"Token required - not valid tokenless upload"}
==> Failed to create-commit
    Exiting...
Error: Process completed with exit code 1.

This issue also appears to be described in https://github.com/codecov/codecov-action/issues/1645#issuecomment-2483261997

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 15 (8 by maintainers)

Most upvoted comments

@MarcHagen can you try the latest and see if it’s working for you?

@Cardds fyi the fix that strips out the newline is in the Action now

@MarcHagen are you able to link that CI run by chance?

No sorry, private repo in (non-public) organization.

@Cardds I believe you might have a newline character at the end of your CODECOV_TOKEN, can you double-check that?

@thomasrockhu-codecov

~Still saying Fork detected, tokenless uploading used but at least it now uploads to codecov.io, so it somehow uses the token correctly now~ 👍🏻

EDIT: PRs not working…

<<SNIP>>
##[debug]/usr/bin/bash --noprofile --norc -e -o pipefail /home/runner/_work/_temp/83453b81-af03-4376-bebc-ef55db4eadf1.sh
##[debug]CC_TOKEN=''
##[debug]Finished: run
##[debug]Evaluating: inputs.override_branch
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'override_branch'
##[debug]=> ''
##[debug]Result: ''
##[debug]Evaluating: github.event.pull_request.head.label
##[debug]Evaluating Index:
##[debug]..Evaluating Index:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating github:
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'event'
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'pull_request'
##[debug]....=> null
##[debug]..=> null
##[debug]=> null
##[debug]Result: null
##[debug]Evaluating: github.event.pull_request.repo.full_name
##[debug]Evaluating Index:
##[debug]..Evaluating Index:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating github:
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'event'
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'pull_request'
##[debug]....=> null
##[debug]..=> null
##[debug]=> null
##[debug]Result: null
##[debug]Evaluating: github.repository
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'repository'
##[debug]=> 'something-org/something-repo'
##[debug]Result: 'something-org/something-repo'
##[debug]Evaluating condition for step: 'run'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: run
##[debug]Loading inputs
##[debug]Loading env
Run if [ -z "$CC_BRANCH" ] && [ -z "$CC_TOKEN" ] && [ -n "$GITHUB_EVENT_PULL_REQUEST_REPO_FULL_NAME"] && [ "${GITHUB_EVENT_PULL_REQUEST_REPO_FULL_NAME}" != "$GITHUB_REPOSITORY" ];
##[debug]/usr/bin/bash --noprofile --norc -e -o pipefail /home/runner/_work/_temp/ed21e8f6-a12a-43c6-992d-e57af7767f6c.sh
==> Fork detected, tokenless uploading used
<<SNIP>>
Run ${GITHUB_ACTION_PATH}/dist/codecov.sh
##[debug]/usr/bin/bash --noprofile --norc -e -o pipefail /home/runner/_work/_temp/09f80618-f348-446a-96f7-0480b40eb908.sh
     _____          _
    / ____|        | |
   | |     ___   __| | ___  ___ _____   __
   | |    / _ \ / _` |/ _ \/ __/ _ \ \ / /
   | |___| (_) | (_| |  __/ (_| (_) \ V /
    \_____\___/ \__,_|\___|\___\___/ \_/
                            Wrapper-0.0.24
                                  
==> Detected linux
 -> Downloading https://cli.codecov.io/latest/linux/codecov
==> Finishing downloading linux:latest
      Version: v9.0.4
 
gpg: directory '/home/runner/.gnupg' created
gpg: keybox '/home/runner/.gnupg/pubring.kbx' created
gpg: /home/runner/.gnupg/trustdb.gpg: trustdb created
gpg: key 806BB28AED779869: public key "Codecov Uploader (Codecov Uploader Verification Key) <security@codecov.io>" imported
gpg: Total number processed: 1
gpg:               imported: 1
==> Verifying GPG signature integrity
 -> Downloading https://cli.codecov.io/latest/linux/codecov.SHA256SUM
 -> Downloading https://cli.codecov.io/latest/linux/codecov.SHA256SUM.sig
 
gpg: Signature made Fri Nov 15 18:59:14 2024 UTC
gpg:                using RSA key 27034E7FDB850E0BBC2C62FF806BB28AED779869
gpg: Good signature from "Codecov Uploader (Codecov Uploader Verification Key) <security@codecov.io>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 2703 4E7F DB85 0E0B BC2C  62FF 806B B28A ED77 9869
codecov: OK
==> CLI integrity verified

 -> Token of length 0 detected
==> Running create-commit
      ./codecov  create-commit --fail-on-error --git-service github
info - 2024-11-19 21:05:29,883 -- ci service found: github-actions
info - 2024-11-19 21:05:30,344 -- Process Commit creating complete
 
==> Running create-report
      ./codecov  create-report --fail-on-error --git-service github
info - 2024-11-19 21:05:31,375 -- ci service found: github-actions
info - 2024-11-19 21:05:32,018 -- Process Report creating complete
info - 2024-11-19 21:05:32,019 -- Finished creating report successfully --- {"response": "{\"status\":\"queued\"}\n"}
 
==> Running do-upload
      ./codecov  do-upload  --fail-on-error  --file  clover.xml  --gcov-executable gcov  --git-service github  --name codecov-8.3
info - 2024-11-19 21:05:33,045 -- ci service found: github-actions
warning - 2024-11-19 21:05:33,069 -- xcrun is not installed or can't be found.
warning - 2024-11-19 21:05:33,070 -- gcov is not installed or can't be found.
warning - 2024-11-19 21:05:33,070 -- coverage.py is not installed or can't be found.
info - 2024-11-19 21:05:33,289 -- Found 1 coverage files to report
info - 2024-11-19 21:05:33,289 -- > /home/runner/_work/something-repo/something-repo/clover.xml
info - 2024-11-19 21:05:33,648 -- Your upload is now processing. When finished, results will be available at: https://app.codecov.io/github/something-org/something-repo/commit/shacommit
info - 2024-11-19 21:05:33,946 -- Process Upload complete
<<SNIP>>

@Cardds I pushed out 5.0.3, would you be able to see if that works for you?