Uh oh!
There was an error while loading. Please reload this page.
fix(core): Guard nullish response in supabase PostgREST handler - #20033
Conversation
The `.then()` success handler in `instrumentPostgRESTFilterBuilder` accessed `res.error` without a null guard, causing a crash when `res` is undefined (observed in React Native). This adds a guard matching the pattern already used in `instrumentAuthOperation`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Deps
Nuxt
Other
Bug Fixes 🐛
Documentation 📚
Internal Changes 🔧Core
Deps
Deps Dev
Other
🤖 This preview updates automatically when you update the PR. |
size-limit report 📦
|
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
Address lint failures: use `res?.error` instead of `res && res.error`, and remove unused imports in the test file. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Lms24
left a comment
There was a problem hiding this comment.
Good catch, thanks! Wasn't aware that a response from Supabase could be nullish but didn't think of the custom fetch implementation. Makes sense to guard for this!
Uh oh!
There was an error while loading. Please reload this page.
Closes#20032 ### Context: In the `supabaseIntegration`'s PostgREST instrumentation, the `.then()` success handler accesses `res.error` without checking if `res` is nullish first. This causes crashes in environments like React Native where the response can be `undefined`. A related error recently trended on the React Native SDK (see Linear comment) ### Summary: - Added a null guard on `res` before accessing `res.error` in `instrumentPostgRESTFilterBuilder`, changing `if (res.error)` to `if (res && res.error)` — matching the existing pattern used in `instrumentAuthOperation` - The existing `setHttpStatus` block already had a proper guard (`if (res && typeof res === 'object' && 'status' in res)`), so only the error-handling path was affected - Span `.end()` and breadcrumb creation continue to work correctly regardless of whether `res` is nullish - Added a new test file for the supabase integration covering the nullish response scenario and existing utility functions Before submitting a pull request, please take a look at our [Contributing](https://github.com/getsentry/sentry-javascript/blob/master/CONTRIBUTING.md) guidelines and verify: - [x] If you've added code that should be tested, please add tests. - [x] Ensure your code lints and the test suite passes (`yarn lint`) & (`yarn test`). - [x] Link an issue if there is one related to your pull request. If no issue is linked, one will be auto-generated and linked. --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Closes#20032
Context:
In the
supabaseIntegration's PostgREST instrumentation, the.then()success handler accessesres.errorwithout checking ifresis nullish first. This causes crashes in environments like React Native where the response can beundefined.A related error recently trended on the React Native SDK (see Linear comment)
Summary:
resbefore accessingres.errorininstrumentPostgRESTFilterBuilder, changingif (res.error)toif (res && res.error)— matching the existing pattern used ininstrumentAuthOperationsetHttpStatusblock already had a proper guard (if (res && typeof res === 'object' && 'status' in res)), so only the error-handling path was affected.end()and breadcrumb creation continue to work correctly regardless of whetherresis nullishBefore submitting a pull request, please take a look at our
Contributing guidelines and verify:
yarn lint) & (yarn test).