codecov / codecov/codecov-action

[BUG] REGRESSION: v5 fails if a broken symlink is present in the repo

Open
#1,890 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
1.7k
Forks
260
Avg merge
1d 7h
Merged PRs (30d)
1

Description

Describe the bug

CI fails with this error:

Traceback (most recent call last):
  File "codecov_cli/main.py", line 100, in <module>
  File "codecov_cli/main.py", line 96, in run
  File "click/core.py", line 1161, in __call__
  File "click/core.py", line 1082, in main
  File "click/core.py", line 1697, in invoke
  File "click/core.py", line 1443, in invoke
  File "click/core.py", line 788, in invoke
  File "click/decorators.py", line 33, in new_func
  File "codecov_cli/commands/upload_coverage.py", line 86, in upload_coverage
  File "click/core.py", line 788, in invoke
  File "codecov_cli/services/upload_coverage/__init__.py", line 52, in upload_coverage_logic
  File "codecov_cli/services/upload/__init__.py", line 104, in do_upload_logic
  File "codecov_cli/services/upload/upload_collector.py", line 194, in generate_upload_data
  File "codecov_cli/services/upload/upload_collector.py", line 104, in _produce_file_fixes
  File "codecov_cli/services/upload/upload_collector.py", line 118, in _get_file_fixes
FileNotFoundError: [Errno 2] No such file or directory: 'internal/integrationtest/compile_4/testdata/ValidSketchWithNonInoBrokenSketchFileSymlink/other_file.c'
[PYI-2973:ERROR] Failed to execute script 'main' due to unhandled exception!
==> Failed to run upload-coverage
    Exiting...

the "missing" file is a broken symlink that we use in our integration tests suite:

$ ls -l internal/integrationtest/compile_4/testdata/ValidSketchWithNonInoBrokenSketchFileSymlink/
total 4
lrwxrwxrwx 1 cmaglie cmaglie  6 feb 28 15:58 other_file.c -> broken
-rw-rw-r-- 1 cmaglie cmaglie 31 feb 28 15:58 ValidSketchWithNonInoBrokenSketchFileSymlink.ino

The best fix in our use case is to catch the "No such file or directory" exception and ignore it.

To Reproduce

I think you can reproduce the error by creating a broken link in the Git repository where a test CI is run.
For example, on Linux:

$ ln -s broken link
$ ls -l link
lrwxrwxrwx 1 cmaglie cmaglie 6 ott 29 12:18 link -> broken
$ git add link
$ git commit -m "Added broken link"

and rerun the CI.

Expected behavior

A successful build.

Regression

The error has already been reported and fixed in the past: https://github.com/codecov/codecov-action/issues/1433

Product Area

Code coverage in CI.

Versions

  • CI/CD: GitHub Actions
  • Uploader: codecov-action@v5

Commit and CI link

You can see it here until it lasts: https://github.com/arduino/arduino-cli/actions/runs/18904016674/job/53963368281?pr=3019#step:8:364

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in codecov_cli/services/upload/upload_collector.py, especially _produce_file_fixes and _get_file_fixes, using the traceback to follow file handling. Reproduce the failure with a broken symlink in a Git repository and verify that coverage upload completes successfully without failing on the missing target.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ci-cd
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.