fix(sentry): null-coalesce PostgREST details/hint to prevent TypeError#945
Merged
sw-factory-automations merged 1 commit intomainfrom May 7, 2026
Merged
Conversation
PostgREST 500 responses return `details: null` and `hint: null`. The `isPostgrestError` duck-type check uses the `in` operator which returns true when the key exists regardless of value type. Calling `null.startsWith()` or `null.includes()` in `isTransientNetworkError` and `isSupabaseAuthLockError` crashes the retry logic, turning a retryable Supabase 500 into an unhandled rejection. - Update `isPostgrestError` type guard to reflect nullable fields - Add `?? ""` null coalescing in isTransientNetworkError, isSupabaseAuthLockError, and captureSupabaseError - Add regression tests for null details/hint - Document null-safety convention in .agents/conventions.md Closes #944 Co-authored-by: Ona <no-reply@ona.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
Author
|
✅ UI verification skipped — no UI files changed. This PR only modifies |
Collaborator
Author
|
✅ Post-merge verification passed. E2E tests against live site (https://memo.software-factory.dev):
Ad-hoc smoke tests:
Skipped:
|
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.
Summary
PostgREST 500 responses return
details: nullandhint: null. TheisPostgrestErrorduck-type check uses theinoperator, which returnstruewhen the key exists regardless of value type. Callingnull.startsWith()ornull.includes()inisTransientNetworkErrorandisSupabaseAuthLockErrorcrashes the retry logic, turning a retryable Supabase 500 into an unhandled rejection that crashes the page.Sentry issue: https://ona-2j.sentry.io/issues/MEMO-2E — 2 events, 1 user, unhandled.
Closes #944
Root Cause
retryOnNetworkError()callsisTransientNetworkError(result.error)isPostgrestError()returnstrue(all 4 keys exist on the error object)error.detailsisnull(PostgREST 500 response)null.startsWith()→TypeError: Cannot read properties of null (reading 'startsWith')Changes
src/lib/sentry.ts: UpdateisPostgrestErrortype guard to reflect thatdetailsandhintcan benull. Add?? ""null coalescing inisTransientNetworkError,isSupabaseAuthLockError, andcaptureSupabaseError.src/lib/sentry.unit.test.ts: Add regression tests for PostgREST errors withdetails: nullandhint: nullacross all three affected functions..agents/conventions.md: Document the null-safety convention for PostgREST fields.Testing
pnpm lint— 0 errorspnpm typecheck— passespnpm test— 1812 tests pass (132 files)