From 500e108892c3a311917aa6ea8f4b343f537a6941 Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Thu, 27 Aug 2026 22:48:14 +0000 Subject: [PATCH] fix: handle FileNotFoundError for temporary coverage files --- codecov_cli/services/upload/upload_sender.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/codecov_cli/services/upload/upload_sender.py b/codecov_cli/services/upload/upload_sender.py index db8658d3..7af3f634 100644 --- a/codecov_cli/services/upload/upload_sender.py +++ b/codecov_cli/services/upload/upload_sender.py @@ -189,10 +189,21 @@ def _get_file_fixers( return file_fixers def _get_files(self, upload_data: UploadCollectionResult): - return [self._format_file(file) for file in upload_data.files] + return [ + result + for result in (self._format_file(file) for file in upload_data.files) + if result is not None + ] def _format_file(self, file: UploadCollectionResultFile): - format, formatted_content = self._get_format_info(file) + try: + format, formatted_content = self._get_format_info(file) + except FileNotFoundError: + logger.warning( + f"Coverage file not found, skipping: {file.get_filename()}. " + "The file may have been removed before upload (e.g. a temporary coverage file cleaned up by the test framework)." + ) + return None return { "filename": file.get_filename(), "format": format,