Skip to content

Conversation

@drazisil-codecov
Copy link
Contributor

  • Added detailed logging in the initialize_and_save_report method of ReportService to track the report creation and backfilling process.
  • Improved error handling in UploadTask to log unexpected errors during report initialization, ensuring better visibility into issues.
  • Included success messages for report initialization and saving, enhancing overall logging clarity.

… traceability

- Added detailed logging in the initialize_and_save_report method of ReportService to track the report creation and backfilling process.
- Improved error handling in UploadTask to log unexpected errors during report initialization, ensuring better visibility into issues.
- Included success messages for report initialization and saving, enhancing overall logging clarity.
@linear
Copy link

linear bot commented Nov 10, 2025

@drazisil-codecov
Copy link
Contributor Author

@sentry review

@sentry
Copy link

sentry bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.84%. Comparing base (62b3cda) to head (0c24f19).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #556   +/-   ##
=======================================
  Coverage   93.84%   93.84%           
=======================================
  Files        1284     1284           
  Lines       46318    46325    +7     
  Branches     1524     1524           
=======================================
+ Hits        43469    43476    +7     
  Misses       2540     2540           
  Partials      309      309           
Flag Coverage Δ
workerintegration 58.76% <42.85%> (-0.01%) ⬇️
workerunit 91.15% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov-notifications
Copy link

codecov-notifications bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

- Removed redundant info logs in the initialize_and_save_report method of ReportService to streamline the logging process.
- Changed some info logs to debug level for less verbosity during normal operations.
- Updated UploadTask to remove success log after report initialization, focusing on error handling instead.
- Added a new test to verify logging of unexpected errors during report initialization in UploadTask.
- Refactored logging in ReportService to improve clarity and structure, ensuring consistent formatting in log messages.
@drazisil-codecov
Copy link
Contributor Author

@sentry review

- Cleaned up unnecessary whitespace in the test_upload_task.py file to enhance code clarity and maintain consistent formatting.
- Ensured that the test structure remains intact while improving overall readability.
- Changed the logging of the files count in the ReportService to use the total files count from the report instead of the length of the files list, improving accuracy in the report details.
- Added mocks for functions that run before `initialize_and_save_report` in the `TestUploadTaskUnit` class to isolate tests and improve reliability.
- This change ensures that tests can focus on error handling without external dependencies affecting outcomes.
@drazisil-codecov
Copy link
Contributor Author

@sentry review

- Updated the ReportService to include a fallback mechanism for the files count in the logging process, ensuring accurate reporting even if totals computation fails.
- Improved log details by including the repository ID alongside the commit ID for better traceability.
- Implemented a call to log breadcrumbs when unexpected errors occur during the upload process, enhancing error tracking and visibility.
- Updated unit tests to verify that the breadcrumb logging is correctly triggered with the appropriate parameters, ensuring robust error handling in UploadTask.
@drazisil-codecov
Copy link
Contributor Author

@sentry review

- Modified the ReportService to log the total files count directly from the report object, removing the fallback mechanism for improved accuracy in logging.
- This change enhances the clarity of the log messages by ensuring that the correct files count is always reported.
- Updated the unit test for UploadTask to use assert_called_once_with for verifying error logging, ensuring both call count and arguments are checked.
- This change enhances the accuracy of error context in logs, improving overall test reliability and clarity.
@drazisil-codecov
Copy link
Contributor Author

@sentry review

Comment on lines 555 to +575
error=Errors.INTERNAL_RETRYING,
)
self.retry(countdown=60, kwargs=upload_context.kwargs_for_retry(kwargs))
except Exception as e:
log.error(
"Unexpected error during initialize_and_save_report",
extra={
**upload_context.log_extra(),
"error_type": type(e).__name__,
"error_message": str(e),
},
exc_info=True,
)
self._call_upload_breadcrumb_task(
commit_sha=commit.commitid,
repo_id=repository.repoid,
milestone=Milestones.COMPILING_UPLOADS,
error=Errors.UNKNOWN,
error_text=repr(e),
)
raise
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling for unexpected exceptions during initialize_and_save_report calls _call_upload_breadcrumb_task with error=Errors.UNKNOWN, which is appropriate for catching unexpected errors. However, make sure that other report service implementations (BundleAnalysisReportService, TestResultsReportService) don't override this method in a way that would bypass this error handling. If they do, the exception handling should be applied consistently across all report service implementations.
Severity: MEDIUM

🤖 Prompt for AI Agent

Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: apps/worker/tasks/upload.py#L555-L575

Potential issue: The error handling for unexpected exceptions during
`initialize_and_save_report` calls `_call_upload_breadcrumb_task` with
`error=Errors.UNKNOWN`, which is appropriate for catching unexpected errors. However,
make sure that other report service implementations (BundleAnalysisReportService,
TestResultsReportService) don't override this method in a way that would bypass this
error handling. If they do, the exception handling should be applied consistently across
all report service implementations.

Did we get this right? 👍 / 👎 to inform future reviews.

…ed clarity

- Updated the unit test for UploadTask to replace assert_called_once_with with explicit assertions for call count and arguments, improving test readability and reliability.
- This change ensures that the error logging behavior is thoroughly verified, including the message and additional context details.
@drazisil-codecov drazisil-codecov added this pull request to the merge queue Nov 11, 2025
Merged via the queue into main with commit 21a85a5 Nov 11, 2025
39 checks passed
@drazisil-codecov drazisil-codecov deleted the CCMRG-1862_add-extra-logging-to-upload-task branch November 11, 2025 13:07
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.

3 participants