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

Reset request body on retry #774

Merged
merged 1 commit into from Jun 10, 2022
Merged

Reset request body on retry #774

merged 1 commit into from Jun 10, 2022

Conversation

embano1
Copy link
Member

@embano1 embano1 commented Jun 9, 2022

Fixes a bug where requests with a body (event) are not always retried due to the underlying net/http throwing *url.Error because of body and content-length mismatch (body is empty and not reset upon retry). See #773 for details.

The tests did not catch this as they were not doing behaving as a real HTTP server (just mocking RoundTripper) and also not carrying an event body (which would not trigger this behavior).

  • Changed retry tests to use a network connection and HTTP (test) server
  • Reset body (if not nil) during retries
  • Set GetBody func only if it is not already set (the sdk already does this currently)

Closes: #773
Signed-off-by: Michael Gasch mgasch@vmware.com

@embano1 embano1 changed the title fix: Reset request body on retry Reset request body on retry Jun 9, 2022
Closes: cloudevents#773
Signed-off-by: Michael Gasch <mgasch@vmware.com>
@embano1
Copy link
Member Author

embano1 commented Jun 9, 2022

Linter workflow seems broken.

Running locally only throws a small (existing) nit:

golangci-lint run
protocol/http/result_test.go:95:5: S1038: should use t.Errorf(...) instead of t.Error(fmt.Sprintf(...)) (gosimple)
                                t.Error(fmt.Sprintf("%v, expected result to be IsUndelivered == %t, got %t", tc.name, tc.want, got))

@n3wscott
Copy link
Member

Thank you so much @embano1 !! Both for the detailed bug report and the follow-up fix. I will cherry-pick this into the current release as a bug fix and we will get this out. 🙏 🙏 🙏

@n3wscott n3wscott merged commit 249465f into cloudevents:main Jun 10, 2022
@embano1 embano1 deleted the issue-773 branch June 10, 2022 15:01
n3wscott added a commit that referenced this pull request Jun 10, 2022
Closes: #773
Signed-off-by: Michael Gasch <mgasch@vmware.com>

Co-authored-by: Michael Gasch <mgasch@vmware.com>
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.

req.Body not reset in doWithRetry
2 participants