Aws-sdk-go: Getting "Request body type has been overwritten. May cause race conditions" log message when requests are retried

Created on 3 Oct 2016  路  6Comments  路  Source: aws/aws-sdk-go

I'm currently using version 1.4.14.

I have some code that makes an elb.ELB.DescribeTags() call. That method then calls request.Request.Send(). The Send method, if it encounters an error and decides to retry, checks to see if the http request body is an *offsetReader. If it isn't, it prints this log message (which was added by pull request 574).

I am getting the "Request body type has been overwritten" log message, and I believe I have figured out why. The request.Request.Send() method calls the Sign method, which runs a series of handlers on this line. One of the handlers that runs appears to be the v4.SignRequestHandler. This handler seems to end up running this line of code, which resets the reader to an ioutil.NopCloser.

Even if no retry occurs, this reset appears to occur, but you of course only see the log message if a retry occurs.

bug

All 6 comments

I'm also getting this warning (with the lambda client, but the root cause is the same).

Hello @keiths-osc and @coopernurse, thank you for reaching out to us. We have taken a look at this and see where the issue is arising from. I think the fix requires us to wrap the request.Body as an offsetReader in an internal Request field. So after the build handler, we can set up this field. Then when we get to copyHTTPRequest for retries, we can set Body to this internal field. Additionally, we are more than happy to take PRs!

@keiths-osc and @coopernurse, PR #871 should resolve this! If you have any additional questions, please let us know!

Hi @keiths-osc and @coopernurse, I just merged #874, and this fixes the issue of the SDK's Request reader potentially encountering race condition. Let us know if you have any issues, or feedback.

Fantastic, thank you for the quick work on this.

Thank you!

Was this page helpful?
0 / 5 - 0 ratings