Skip to content

fix: gracefully handle missing files during upload - #766

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/handle-missing-upload-files
Open

fix: gracefully handle missing files during upload#766
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/handle-missing-upload-files

Conversation

@sentry

@sentry sentry Bot commented Aug 20, 2026

Copy link
Copy Markdown

This PR addresses issue CLI-3E, where the Codecov CLI would crash with a FileNotFoundError if a coverage file, discovered during the search phase, was no longer present or accessible when its content was being read for upload.

The root cause was a TOCTOU (Time-of-Check to Time-of-Use) race condition: a file like coverage.json might be found by the file search, but then deleted or become a broken symlink before the upload process could read its content. The previous implementation in _get_files in upload_sender.py did not handle this scenario, leading to an unhandled exception and a failed upload.

Changes Made:

  • Modified the _get_files method in codecov_cli/services/upload/upload_sender.py.
  • Replaced the list comprehension with an explicit loop to process each file individually.
  • Wrapped the file content reading (self._format_file(file)) in a try-except FileNotFoundError block.
  • If a FileNotFoundError occurs for a specific file, a warning is now logged (e.g., "File not found, skipping: /path/to/missing/file"), and that file is skipped, allowing the upload of other valid files to proceed without interruption.

Fixes CLI-3E

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
723 1 722 1
View the full list of 1 ❄️ flaky test(s)
api.temp.calculator.test_calculator::test_divide

Flake rate in main: 100.00% (Passed 0 times, Failed 1726 times)

Stack Traces | 0.001s run time
def
                test_divide():
                > assert Calculator.divide(1, 2) == 0.5
                E assert 1.0 == 0.5
                E + where 1.0 = <function Calculator.divide at 0x104c9eb90>(1, 2)
                E + where <function Calculator.divide at 0x104c9eb90> = Calculator.divide
                .../temp/calculator/test_calculator.py:30: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

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 this pull request may close these issues.

0 participants