-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(httpclient): Do not send undefined headers #8009
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
Conversation
size-limit report 📦
|
}, | ||
}); | ||
expect(eventData.request?.headers).toEqual({ | ||
'User-Agent': expect.any(String), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of interest, how would this test previously fail? meaning, what used to happen before this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should instead change normalize
to drop undefined
values. Normalizing it to strings is weird.
Given we merged and released #8017, we can probably close this PR right? |
Before submitting a pull request, please take a look at our
Contributing guidelines and verify:
yarn lint
) & (yarn test
).If
sendDefaultPii: false
normalized"[undefined]"
headers should not be sent.