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(utils): Ensure dropUndefinedKeys() does not break class instances #10245

Merged
merged 3 commits into from Jan 18, 2024

Conversation

mydea
Copy link
Member

@mydea mydea commented Jan 18, 2024

The old implementation of dropUndefinedKeys() could break things, because it used isPlainObject() which actually does not check if something is a POJO, but just any object. So any class instance found somewhere would be broken by this.

This PR fixes this to check for POJOs better, and leaves class instances alone.

Supersedes https://github.com/getsentry/sentry-javascript/pull/10242/files

Copy link
Contributor

github-actions bot commented Jan 18, 2024

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 77.55 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 68.82 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) - Webpack (gzipped) 72.7 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 62.46 KB (+0.05% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 32.83 KB (+0.09% 🔺)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 31.15 KB (+0.08% 🔺)
@sentry/browser (incl. sendFeedback) - Webpack (gzipped) 31.16 KB (+0.09% 🔺)
@sentry/browser - Webpack (gzipped) 22.51 KB (+0.14% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 75.14 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 66.75 KB (+0.05% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 32.6 KB (+0.08% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 24.21 KB (+0.11% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 210.37 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 98.34 KB (+0.13% 🔺)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 72.46 KB (+0.17% 🔺)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 35.65 KB (+0.08% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 69.23 KB (+0.04% 🔺)
@sentry/react - Webpack (gzipped) 22.55 KB (+0.14% 🔺)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 85.82 KB (+0.04% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 49.95 KB (+0.05% 🔺)
@sentry-internal/feedback - Webpack (gzipped) 17.14 KB (+0.17% 🔺)

@@ -144,3 +145,27 @@ describe('isVueViewModel()', () => {
expect(isVueViewModel({ foo: true })).toEqual(false);
});
});

describe('isPlainObject', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

While at it, I at least added tests here for the current behavior!

@mydea mydea enabled auto-merge (squash) January 18, 2024 14:19
@mydea mydea merged commit a9e52e7 into develop Jan 18, 2024
94 checks passed
@mydea mydea deleted the fn/dropUndefinedKeysPojo branch January 18, 2024 19:04
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.

None yet

2 participants