Improve error handling in background workers

What does this MR do and why?

Recently we were getting the errors related to the incorrect error handling. Example:

  1. ActiveRecord::QueryCanceled is raised when searching for an object by id logs (internal).
  2. The error is caught by the rescue block and handled by process_package_file_error.
  3. package_file doesn't exist => different error is raised undefined method 'project_id' for nil:NilClass (NoMethodError) sentry (internal).

This MR adds the guard to the rescue block to verify if package file exists before processing the error.

References

Screenshots or screen recordings

No.

How to set up and validate locally

The changes are straightforward and, I think, covering them with the tests should be enough.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #578214

Edited by Dzmitry (Dima) Meshcharakou

Merge request reports

Loading