Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

fix(errors): Use WithNoOverwrite instead of WithOptionalSeverity #975

Merged
merged 3 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ func configureAwsClient(ctx context.Context, logger hclog.Logger, awsConfig *Con
// Test out retrieving credentials
if _, err := awsCfg.Credentials.Retrieve(ctx); err != nil {
logger.Error("error retrieving credentials", "err", err)
return awsCfg, classifyError(fmt.Errorf(awsFailedToConfigureErrMsg, account.AccountName, err, checkEnvVariables()), diag.INTERNAL, nil, diag.WithSeverity(diag.ERROR))
return awsCfg, classifyError(fmt.Errorf(awsFailedToConfigureErrMsg, account.AccountName, err, checkEnvVariables()), diag.INTERNAL, nil, diag.WithSeverity(diag.ERROR), diag.WithNoOverwrite())
}

return awsCfg, err
Expand Down Expand Up @@ -517,7 +517,7 @@ func Configure(logger hclog.Logger, providerConfig interface{}) (schema.ClientMe
}
})
if err != nil {
return nil, diags.Add(classifyError(fmt.Errorf("failed to find disabled regions for account %s. AWS Error: %w", account.AccountName, err), diag.INTERNAL, nil, diag.WithSeverity(diag.ERROR)))
return nil, diags.Add(classifyError(fmt.Errorf("failed to find disabled regions for account %s. AWS Error: %w", account.AccountName, err), diag.INTERNAL, nil, diag.WithSeverity(diag.ERROR), diag.WithNoOverwrite()))
}
account.Regions = filterDisabledRegions(localRegions, res.Regions)

Expand Down
10 changes: 5 additions & 5 deletions client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func classifyError(err error, fallbackType diag.Type, accounts []Account, opts .
diag.ACCESS,
append(opts,
diag.WithType(diag.ACCESS),
diag.WithOptionalSeverity(diag.WARNING),
diag.WithSeverity(diag.WARNING),
ParseSummaryMessage(err),
diag.WithDetails(errorCodeDescriptions[ae.ErrorCode()]),
)...),
Expand All @@ -79,7 +79,7 @@ func classifyError(err error, fallbackType diag.Type, accounts []Account, opts .
diag.ACCESS,
append(opts,
diag.WithType(diag.ACCESS),
diag.WithOptionalSeverity(diag.WARNING),
diag.WithSeverity(diag.WARNING),
ParseSummaryMessage(err),
diag.WithDetails("Something is wrong with your credentials. Either the accessKeyId or secretAccessKey (or both) are wrong."),
)...),
Expand All @@ -93,7 +93,7 @@ func classifyError(err error, fallbackType diag.Type, accounts []Account, opts .
diag.ACCESS,
append(opts,
diag.WithType(diag.ACCESS),
diag.WithOptionalSeverity(diag.WARNING),
diag.WithSeverity(diag.WARNING),
ParseSummaryMessage(err),
diag.WithDetails("Something is wrong with your credentials. Ensure you have access to the specified resource."),
)...),
Expand All @@ -106,7 +106,7 @@ func classifyError(err error, fallbackType diag.Type, accounts []Account, opts .
diag.RESOLVING,
append(opts,
diag.WithType(diag.RESOLVING),
diag.WithOptionalSeverity(diag.IGNORE),
diag.WithSeverity(diag.IGNORE),
ParseSummaryMessage(err),
diag.WithDetails("The action is invalid for the service."),
)...),
Expand All @@ -133,7 +133,7 @@ func classifyError(err error, fallbackType diag.Type, accounts []Account, opts .
diag.THROTTLE,
append(opts,
diag.WithType(diag.THROTTLE),
diag.WithOptionalSeverity(diag.WARNING),
diag.WithSeverity(diag.WARNING),
ParseSummaryMessage(err),
diag.WithDetails("CloudQuery AWS provider has been throttled. This is unexpected - you can open an issue on github (https://github.com/cloudquery/cq-provider-aws/issues) or contact us on discord (https://cloudquery.io/discord)"),
)...),
Expand Down