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:
-
ActiveRecord::QueryCanceledis raised when searching for an object by id logs (internal). - The error is caught by the
rescueblock and handled byprocess_package_file_error. -
package_filedoesn't exist => different error is raisedundefined 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