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

fix: request body logging [#84] #94

Merged
merged 2 commits into from
Dec 10, 2019
Merged

Conversation

flash286
Copy link
Contributor

fix: request body logging [#84]

@rhcarvalho rhcarvalho self-requested a review November 27, 2019 11:04
@rhcarvalho
Copy link
Contributor

@flash286 thank you for the pull request! The approach looks good.

I would like to investigate a bit more before merging. In particular, look at the integrations that use FromHTTPRequest -- it may be the case that the body was read and is not available anymore when we want to report an error.

Will give more review feedback tomorrow, wanted to keep you posted ;)

Once again thank you!

Copy link
Contributor

@rhcarvalho rhcarvalho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flash286 thanks for your contribution! Special awesomeness medal 🥇 for adding tests!

I'd like @kamilogorek to have a look at this too as he may have some insights.

interfaces.go Show resolved Hide resolved

const testPayload = `{"test_data": true}`

func TestRequest_FromHTTPRequest(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's awesome to see tests for this, thank you very much!!! ❤️

We follow the Go MixedCaps naming convention, could you please update the function name to TestRequestFromHTTPRequest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

sentryRequest := Request{}
sentryRequest = sentryRequest.FromHTTPRequest(req)
assertEqual(t, sentryRequest.Data, testPayload)
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body of the first test is exactly the same as the early portion of the second test.

Since the assert* helpers call t.Error, execution continues even after an "assertion error". In that case, I think it is enough to have just the second test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I Agree, second one should cover all we need

"testing"
)

const testPayload = `{"test_data": true}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is not used anywhere else and to avoid polluting the global namespace for tests, how about we move this inside of the test method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

interfaces.go Show resolved Hide resolved
@kamilogorek
Copy link
Contributor

Agree with all your comments, nice review!

Copy link
Contributor

@rhcarvalho rhcarvalho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flash286 thanks for the update! I noticed one opportunity to capture the body bytes even when there's an error. Would you like to tackle it in this PR? Extra bonus if that includes a unit test 😄

Otherwise let's merge this in and cut an improvement issue.

interfaces.go Show resolved Hide resolved
interfaces.go Show resolved Hide resolved
Copy link
Contributor

@rhcarvalho rhcarvalho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this in and iterate later if we need.

@rhcarvalho rhcarvalho merged commit c558d82 into getsentry:master Dec 10, 2019
@rhcarvalho
Copy link
Contributor

@flash286 thank you very much for your contribution!

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.

4 participants