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

Error caused by inability to auto register RP clobbers original error surfaced by Azure #683

Closed
sagilson opened this issue Feb 16, 2022 · 1 comment · Fixed by #691
Closed

Comments

@sagilson
Copy link

sagilson commented Feb 16, 2022

return resp, fmt.Errorf("failed auto registering Resource Provider: %s. Original error: %s", regErr, err)

The serviceError that maintains the code "MissingSubscriptionRegistration" is clobbered on the line called out above. This makes it really difficult for users of this client code to properly respond to failures where the customer is not registered for a required RP for our service.
In my RPs case, we are considering doing a string compare for "MissingSubscriptionRegistration" in the error returned, which is very fragile.

Do you have any recommendations on how best to identify "MissingSubscriptionRegistration"?

The easy fix I see is to replace rp.go:67 with the following:
return resp, fmt.Errorf("failed auto registering Resource Provider: %s. Original error: %w", regErr, err)
%w allows for the error to be cleanly unwrapped, as opposed to being embedded as a string, however its only available from go1.13 and onwards.
More details on %w below:
https://go.dev/blog/go1.13-errors#:~:text=Wrapping%20errors%20with%20%25w

Thoughts?

@jhendrixMSFT
Copy link
Member

jhendrixMSFT commented Mar 31, 2022

Fixed in autorest@v0.11.25

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 a pull request may close this issue.

2 participants