fix(httpclient): Do not send undefined headers#8009
Closed
krystofwoldrich wants to merge 2 commits intodevelopfrom
Closed
fix(httpclient): Do not send undefined headers#8009krystofwoldrich wants to merge 2 commits intodevelopfrom
krystofwoldrich wants to merge 2 commits intodevelopfrom
Conversation
Contributor
size-limit report 📦
|
mydea
reviewed
May 2, 2023
| }, | ||
| }); | ||
| expect(eventData.request?.headers).toEqual({ | ||
| 'User-Agent': expect.any(String), |
Member
There was a problem hiding this comment.
out of interest, how would this test previously fail? meaning, what used to happen before this PR?
Contributor
Author
There was a problem hiding this comment.
Like this toMatchObject ignores extra attributes, but toEqual requires values to be exactly the same.
I've updated the test to use toStrictEqual to catch also undefined keys, but the test looked the same with toEqual because the undefined keys were normalized to string.
Running 1 test using 1 worker
✘ 1 …tpclient/fetch/simpleNoPii/test.ts:7:11 › should assign request and response context from a failed 500 fetch request without pii (1.7s)
1) suites/integrations/httpclient/fetch/simpleNoPii/test.ts:7:11 › should assign request and response context from a failed 500 fetch request without pii
Error: expect(received).toEqual(expected) // deep equality
- Expected - 0
+ Received + 3
Object {
+ "body_size": "[undefined]",
+ "cookies": "[undefined]",
+ "headers": "[undefined]",
"status_code": 500,
}
56 | 'User-Agent': expect.any(String),
57 | });
> 58 | expect(eventData.contexts?.response).toEqual({
| ^
59 | status_code: 500,
60 | });
61 | },
at /Users/krystofwoldrich/repos/sentry-javascript/packages/browser-integration-tests/suites/integrations/httpclient/fetch/simpleNoPii/test.ts:58:42
1 failed
suites/integrations/httpclient/fetch/simpleNoPii/test.ts:7:11 › should assign request and response context from a failed 500 fetch request without pii
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lforst
suggested changes
May 2, 2023
Contributor
lforst
left a comment
There was a problem hiding this comment.
IMO we should instead change normalize to drop undefined values. Normalizing it to strings is weird.
Contributor
|
Given we merged and released #8017, we can probably close this PR right? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before submitting a pull request, please take a look at our
Contributing guidelines and verify:
yarn lint) & (yarn test).If
sendDefaultPii: falsenormalized"[undefined]"headers should not be sent.