Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ module Operations
class CreateSecurityUpdatePullRequest
include SecurityUpdateHelpers

class SecurityUpdateFailure < 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,
Expand Down Expand Up @@ -70,7 +81,7 @@ def check_and_create_pr_with_error_handling(dependency)
error_detail: e.message
)
rescue StandardError => e
error_handler.handle_dependency_error(error: e, dependency: dependency)
handle_security_update_failure_error(e, dependency)
end

# rubocop:disable Metrics/AbcSize
Expand Down Expand Up @@ -267,6 +278,24 @@ def create_pull_request(dependency_change)
}.compact
end
end

# rubocop:disable Naming/MethodParameterName
# moves issues
def handle_security_update_failure_error(ex, dependency)
Comment on lines +282 to +284
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be updated so you don't have to disable the cop

if ex.message.include? "No files were updated!"

security_ex = SecurityUpdateFailure.new(message:
"Security Update Error, No files were updated!",
error_context:
ex.instance_variable_get(:@error_context))
security_ex.set_backtrace(ex.backtrace)
error_handler.handle_dependency_error(error: security_ex, dependency: dependency)

else
error_handler.handle_dependency_error(error: ex, dependency: dependency)
end
end
# rubocop:enable Naming/MethodParameterName
end
end
end
Expand Down
Loading