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

fix: ignore error messages from all error types #688

Merged
merged 2 commits into from
Dec 17, 2024
Merged
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
20 changes: 12 additions & 8 deletions gcp/ignore_error_predicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,24 @@ func shouldIgnoreErrorPluginDefault() plugin.ErrorPredicateWithContext {
return func(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData, err error) bool {
gcpConfig := GetConfig(d.Connection)

if gerr, ok := err.(*googleapi.Error); ok {
logger := plugin.Logger(ctx)

// Add to support regex match as per error message
for _, pattern := range gcpConfig.IgnoreErrorMessages {
re := regexp.MustCompile(pattern)
result := re.MatchString(gerr.Message)
if result {
return true
}
// Add to support regex match as per error message
for _, pattern := range gcpConfig.IgnoreErrorMessages {
// TODO: maybe compile these at the connection level for performance reasons
re := regexp.MustCompile(pattern)
result := re.MatchString(err.Error())
if result {
logger.Debug("ignore_error_predicate.shouldIgnoreErrorPluginDefault", "ignore_error_message", err.Error())
return true
}
}

if gerr, ok := err.(*googleapi.Error); ok {
// Added to support regex in not found errors
for _, pattern := range gcpConfig.IgnoreErrorCodes {
if ok, _ := path.Match(pattern, types.ToString(gerr.Code)); ok {
logger.Debug("ignore_error_predicate.shouldIgnoreErrorPluginDefault", "ignore_error_code", err.Error())
return true
}
}
Expand Down
Loading