-
Notifications
You must be signed in to change notification settings - Fork 944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added exception for security update error handling. #9977
base: main
Are you sure you want to change the base?
Changes from 2 commits
66e21c6
d658b26
098fe4c
6b80e43
d3ed7ea
28f3b30
cdc9c91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,17 @@ module Operations | |
class CreateSecurityUpdatePullRequest | ||
include SecurityUpdateHelpers | ||
|
||
class SecurityUpdateError < StandardError | ||
def initialize(message:, error_context:) | ||
super(message) | ||
@error_context = error_context | ||
end | ||
|
||
def sentry_context | ||
{ extra: @error_context } | ||
end | ||
end | ||
|
||
def self.applies_to?(job:) | ||
return false if job.updating_a_pull_request? | ||
# If we haven't been given data for the vulnerable dependency, | ||
|
@@ -69,6 +80,15 @@ def check_and_create_pr_with_error_handling(dependency) | |
error_type: "inconsistent_registry_response", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the error is surfaced here. can we detect the actual transitive failure mode and add a specific error class for that scenario? That way we are not swallowing up all errors. I would expect something like this:
That way, we can ensure we are actually separating out that error category. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abdulapopoola , im working on this |
||
error_detail: e.message | ||
) | ||
rescue StandardError | ||
log_error_for_security_update_failure(dependency: dependency) | ||
end | ||
|
||
def log_error_for_security_update_failure(dependency:) | ||
raise SecurityUpdateError.new( | ||
message: "Security Update Error, No files were updated!", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 Rescuing I think it would be wise to preserve some context. Maybe that happens in the message (i.e. we include the original error's class and/or message), or maybe that's passed along in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @landongrindheim , i have redone the code , earlier issue was that due to a double exception throw ( I have raised a new exception class ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think what Landon was saying is still the case, any error that raises here will now be raised as a |
||
error_context: dependency | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @landongrindheim , i have changed error context to back to thrown exception object. it should maintain the older context information but with a newer exception class. |
||
) | ||
rescue StandardError => e | ||
error_handler.handle_dependency_error(error: e, dependency: dependency) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we call this
TransitiveSecurityUpdateError
for specificity?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i matched with class name convention, specificity would be a good idea for sure. ill wait for someone to review once to be sure in case im missing anything.