Don't try to parse body if HTTP status is not 200#81
Don't try to parse body if HTTP status is not 200#81VladRassokhin wants to merge 1 commit intomasterzen:masterfrom
Conversation
bb74298 to
803af85
Compare
|
Not sure yet seems that test |
803af85 to
9f69534
Compare
|
Removing |
|
@masterzen Could you please take a look? |
masterzen
left a comment
There was a problem hiding this comment.
Sorry for the long delay in looking at your PR, and thanks for sending it.
I understand what you're trying to fix here, but unfortunately the proposed change breaks the fundamental feature of supporting transient Operation Timeout server errors (which are just to tell the client that the command hasn't produced any output in the given time), which are usually just ignored and retried.
I'm all in favor of DRYing the code base by reusing ParseSoapResponse as you did, but for the moment, leave the the forked azure-sdk-for-go imports until I've made clear that we're not supporting older Go environments (since this is a library this has the potential of breaking upstream things).
Would you mind amending your PR so that we still support the Operation Timeout error, but still report straight http errors?
Many thanks,
Brice
| "strings" | ||
| "time" | ||
|
|
||
| "github.com/masterzen/azure-sdk-for-go/core/http" |
There was a problem hiding this comment.
Removing this means we're breaking the compatibility with Go < 1.8.
But maybe we don't care anymore nowadays...
| body, err := body(resp) | ||
| // error in case of incorrect exit code | ||
| if resp.StatusCode != 200 { | ||
| return "", fmt.Errorf("http unexpected status: %s", resp.Status) |
There was a problem hiding this comment.
The problem here is that if you get an operation timeout (which is also an HTTP 500 error), you'll return an error here that the upper layer will not "ignore" anymore (see command.go:134 and you'll break long running commands.
Note that OperationTimeout are SOAP errors, so they need to be parsed.
That's the reason your code breaks the TestOperationTimeoutSupport test (the test is designed to show that getting a timeout doesn't mean the command is aborted, it still runs on the server until there are more output to display).
So, I think we first have to check if the body is a soap+xml, then error as before, but we also have to carry over correctly the error message if it is a straight http error (and not a soap+xml error).
Improves error message from
http response error: 401 - invalid content typeintohttp unexpected status: 401 UnauthorizedAlso unifies imports, code reuse.