Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
store, daemon, client, cmd/snap: handle PASSWORD_POLICY_ERROR #3278
Conversation
|
There seems to be a folding error in the tests:
Maybe travis sets some default terminal width and your local testing didn't capture this? |
|
sigh... there was a bug in the folding code where I'd misunderstood the width parameter: it doesn't take into account the indent. Fixed that, and of course it broke some of those tests... I'd run them locally but it probably picked up my term width :-) |
niemeyer
approved these changes
May 8, 2017
A few comments, and LGTM once they're tuned to your satisfaction.
| @@ -122,6 +130,9 @@ If you understand and want to proceed repeat the command including --classic. | ||
| // TRANSLATORS: %s is an error message (e.g. “cannot yadda yadda: permission denied”) | ||
| msg = fmt.Sprintf(i18n.G(`%s (try with sudo)`), err.Message) | ||
| } | ||
| + case client.ErrorKindPasswordPolicy: | ||
| + usesSnapName = false | ||
| + msg = err.Message |
| @@ -51,10 +51,32 @@ var ( | ||
| UbuntuoneRefreshDischargeAPI = ubuntuoneAPIBase + "/tokens/refresh" | ||
| ) | ||
| +// a stringish is something that can be a []string or a string | ||
| +// like the values of the "extra" documents in error responses | ||
| +type stringish []string |
niemeyer
May 8, 2017
Contributor
Can we name this as stringList instead? stringish forces one to read the documentation at all times to have any idea of what it means (most things are "stringish" :).
| @@ -70,8 +70,27 @@ func (e *ErrDownload) Error() string { | ||
| return fmt.Sprintf("received an unexpected http response code (%v) when trying to download %s", e.Code, e.URL) | ||
| } | ||
| +type ErrPasswordPolicy map[string]stringish |
niemeyer
May 8, 2017
Contributor
These types are not following the standard pattern correctly. They should all be FooError instead of ErrFoo. The latter is applied for values, while the former is applied to types. Okay to not fix here since this was wrong before already, but let's try to fix it at some point in the future.
|
All review feedback is applied, there are two reviews, the tests are green. Merging. |
chipaca commentedMay 5, 2017
•
Edited 1 time
-
chipaca
May 5, 2017
We had the wrong type for SSO errors. This was usually fine, because the most common errors either have no
extrafield, or theextrafield fits in amap[string][]string. But sometimes, and in particular forPASSWORD_POLICY_ERROR, it's amap[string]string. This made the user-visible error you'd get as a result ofPASSWORD_POLICY_ERRORto be unintelligible and unhelpful (a json decode error).Additionally,
PASSWORD_POLICY_ERRORis rather different from other errors that have anextrafield; in these, there is a long, detailed explanation of the cause of the error together with a URL the user needs to go to to address the issue. With this branch this is surfaced appropriately; for example (and the case that triggered this branch),