Skip to content

Condense CatchV2ErrorDetailWithResponse and CatchV2ErrorMessageWithResponse into one#1406

Merged
Steven Gagniere (sgagniere) merged 22 commits intomainfrom
v2-error-detail-message
Aug 30, 2022
Merged

Condense CatchV2ErrorDetailWithResponse and CatchV2ErrorMessageWithResponse into one#1406
Steven Gagniere (sgagniere) merged 22 commits intomainfrom
v2-error-detail-message

Conversation

@sgagniere
Copy link
Member

Checklist

  1. [CRUCIAL] Is the change for CP or CCloud functionalities that are already live in prod?
    • yes: ok

What

Two V2 error catching functions only differed on whether they read the details or message fields, so they've been combined with the detail being preferred, and the message being used if no details are present.

References

n/a

Test & Review

ran all tests without error

@sgagniere Steven Gagniere (sgagniere) requested a review from a team as a code owner August 19, 2022 18:43
Copy link

Choose a reason for hiding this comment

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

Thank you!! Can we also rename responseBody --> errorResponseBody?

Comment on lines 162 to 163
if ok, _ := regexp.MatchString(quotaExceededRegex, detail); ok {
return NewWrapErrorWithSuggestions(err, detail, QuotaExceededSuggestions)

Choose a reason for hiding this comment

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

Not a huge fan that this is hardcoded here... this only applies to one service so it's wasteful to always check for it

Copy link
Member Author

Choose a reason for hiding this comment

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

Which service? There are a few other specialized catchers in this file, maybe we can make a specialized one for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah... this probably needs an updating. I just took a look at some of the quotas by listing them on the CLI. Tried to create 11 environments and hit a quote error that matches quotaExceededRegex, but didn't get the suggestion.

So this hard-coding only prints that suggestion on whatever subset of commands uses (what is now) CatchCCloudV2Error, which is sub-optimal.

Choose a reason for hiding this comment

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

yeah, it would be great if we could only wrap the quota service functions with this catcher

Choose a reason for hiding this comment

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

this might be deserving of a separate pr

Copy link
Member Author

Choose a reason for hiding this comment

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

I can make that my next cleanup task. I'm assuming only create and update subcommands can hit these quota errors.

Choose a reason for hiding this comment

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

We might introduce a new subcommand that also returns that error, so in my opinion the safest thing to do here would be to wrap every function in service_quota.go with a function that iterates through a list of error catchers and applies them one by one. As of right now, that list would just contain errors.CatchCCloudV2Error() and this one.

Copy link
Contributor

@MuweiHe MuweiHe Aug 30, 2022

Choose a reason for hiding this comment

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

New v2 requests to create a resource could result in this (429 if i remember correctly?). Environment won't have this because it was still using v1 to create.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah ok, I didn't realize environment was using v1.

Co-authored-by: Brian Strauch <bstrauch@confluent.io>
Co-authored-by: Brian Strauch <bstrauch@confluent.io>
Co-authored-by: Brian Strauch <bstrauch@confluent.io>
Co-authored-by: Brian Strauch <bstrauch@confluent.io>
@brianstrauch

Steven Gagniere (@sgagniere) Feel free to request a review every time you make changes! I forgot to re-review this one...

Co-authored-by: Brian Strauch <bstrauch@confluent.io>
Co-authored-by: Brian Strauch <bstrauch@confluent.io>
Co-authored-by: Brian Strauch <bstrauch@confluent.io>
@sgagniere Steven Gagniere (sgagniere) deleted the v2-error-detail-message branch August 30, 2022 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants