fix(core): Guard nullish response in supabase PostgREST handler#20033
Merged
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) <[email protected]>
Contributor
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. |
Contributor
size-limit report 📦
|
Contributor
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) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Lms24
approved these changes
Mar 30, 2026
Member
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!
JPeer264
pushed a commit
that referenced
this pull request
Mar 30, 2026
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) <[email protected]>
46 tasks
3 tasks
10 tasks
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.
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).