Skip to content

fix(studio): batch of production Sentry crash fixes#47695

Closed
awaseem wants to merge 2 commits into
masterfrom
aliwaseem/fe-3862-fix-batch-of-production-sentry-crashes-arraynull-guards
Closed

fix(studio): batch of production Sentry crash fixes#47695
awaseem wants to merge 2 commits into
masterfrom
aliwaseem/fe-3862-fix-batch-of-production-sentry-crashes-arraynull-guards

Conversation

@awaseem

@awaseem awaseem commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #47460 (FE-3748) — same non-array/malformed-API-response bug class, for issues that weren't caught in that pass, plus a few unrelated one-offs found while triaging.

Resolves FE-3862

Issues fixed

Sentry Error Fix
JTP pagination.count/projects.length on malformed org projects response Guard in useStatusPageBannerVisibility.ts + normalize org-projects-infinite-query.ts
B3M pagination.count on undefined Guard pagination in org projects infinite query (org-variant of already-fixed B3K)
K2D (destructured parameter) is undefined Normalize projects array in projects-infinite-query.ts
K2H Cannot read properties of undefined (reading 'projects') Same fix as K2D
JCD can't access property "vectorBuckets", features is undefined Missing ?. after .features in project-storage-config-query.ts
JV9 t?.some is not a function Normalize service-status-query.ts to always return an array
H6Y h?.find is not a function Same fix as JV9
K2F t.map is not a function Guard all four entity arrays in Tables.utils.ts formatAllEntities
JVQ m.find is not a function Normalize branches-query.ts to always return an array
K2J Cannot read properties of undefined (reading 'email') Missing ?. after user_metadata in feature-flags.tsx
K2E auth-js userStorage guard error Detect auth-js's user-not-available proxy before reading session.user
JE3 Q.toLowerCase is not a function Coerce q router param to a single string in Logs Explorer
J89 Invalid time value Validate URL-sourced dates before constructing Date in the Logs date picker

Test plan

  • tsc --noEmit clean
  • eslint clean on all changed files
  • Existing unit tests pass (project-storage-config-query.test.tsx, Logs.Datepickers.test.tsx)

Summary by CodeRabbit

  • Bug Fixes
    • Improved stability across the Studio by handling missing or unexpected data more safely in tables, projects, branches, service status, and feature flag checks.
    • Fixed log date selection and log explorer query handling so filters and initial dates behave more consistently.
    • Prevented crashes in several views when optional data is unavailable, helping pages load reliably.

awaseem added 2 commits July 7, 2026 08:14
…s), round 2

Same non-array/malformed-API-response bug class as #47460 (FE-3748), for
issues that weren't caught in that pass.

Fixes SUPABASE-APP-JTP
Fixes SUPABASE-APP-B3M
Fixes SUPABASE-APP-K2D
Fixes SUPABASE-APP-K2H
Fixes SUPABASE-APP-JCD
Fixes SUPABASE-APP-JV9
Fixes SUPABASE-APP-H6Y
Fixes SUPABASE-APP-K2F
Fixes SUPABASE-APP-JVQ

Resolves FE-3862
Fixes SUPABASE-APP-K2J
Fixes SUPABASE-APP-K2E
Fixes SUPABASE-APP-JE3
Fixes SUPABASE-APP-J89

Related to FE-3862
@awaseem awaseem requested a review from a team as a code owner July 7, 2026 14:56
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
design-system Ready Ready Preview, Comment Jul 7, 2026 3:03pm
docs Ready Ready Preview, Comment, Open in v0 Jul 7, 2026 3:03pm
studio-self-hosted Ready Ready Preview, Comment Jul 7, 2026 3:03pm
studio-staging Ready Ready Preview, Comment Jul 7, 2026 3:03pm
ui-library Ready Ready Preview, Comment Jul 7, 2026 3:03pm
zone-www-dot-com Ready Ready Preview, Comment, Open in v0 Jul 7, 2026 3:03pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Jul 7, 2026 3:03pm

Request Review

@supabase

supabase Bot commented Jul 7, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Comment on lines +95 to 103
// auth-js swaps `session.user` for a proxy that throws on any property access when `userStorage`
// is configured but no user is persisted yet. `__isUserNotAvailableProxy` is the one property it allows.
const isSessionUserAvailable =
!!sessionUser &&
(sessionUser as { __isUserNotAvailableProxy?: boolean }).__isUserNotAvailableProxy !== true
const userEmail = isSessionUserAvailable
? (sessionUser?.user_metadata?.email ?? sessionUser?.email)
: undefined
const params = useParams()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This one needs more checking and validation. Claude helped with this one!

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b710793b-4c9a-4bd6-818c-ecdcb0ca68ec

📥 Commits

Reviewing files that changed from the base of the PR and between a6a04f2 and a6f52a4.

📒 Files selected for processing (11)
  • apps/studio/components/interfaces/Database/Tables/Tables.utils.ts
  • apps/studio/components/interfaces/Settings/Logs/Logs.DatePickers.tsx
  • apps/studio/components/interfaces/Settings/Logs/Logs.utils.ts
  • apps/studio/components/layouts/AppLayout/useStatusPageBannerVisibility.ts
  • apps/studio/data/branches/branches-query.ts
  • apps/studio/data/config/project-storage-config-query.ts
  • apps/studio/data/projects/org-projects-infinite-query.ts
  • apps/studio/data/projects/projects-infinite-query.ts
  • apps/studio/data/service-status/service-status-query.ts
  • apps/studio/pages/project/[ref]/logs/explorer/index.tsx
  • packages/common/feature-flags.tsx

📝 Walkthrough

Walkthrough

This PR adds defensive null/array safety checks across several studio components and data-fetching modules: table formatting guards against non-array inputs, log date pickers use new parsing utilities, several queries normalize responses to EMPTY_ARR, and feature-flag/proxy and route-param handling are hardened against undefined or unexpected shapes.

Changes

Defensive Safety Guards

Layer / File(s) Summary
Table/view/foreign-table array guards
apps/studio/components/interfaces/Database/Tables/Tables.utils.ts
formatAllEntities wraps tables, views, materialized views, and foreign tables with Array.isArray checks before mapping, falling back to empty arrays.
Log date picker parsing
apps/studio/components/interfaces/Settings/Logs/Logs.utils.ts, apps/studio/components/interfaces/Settings/Logs/Logs.DatePickers.tsx
New parseSelectedDate helper safely parses date strings via dayjs; Logs.DatePickers uses it with resolveLogTimestamp for initial state and popover-close reset logic.
EMPTY_ARR normalization and optional chaining in data queries
apps/studio/data/branches/branches-query.ts, apps/studio/data/projects/org-projects-infinite-query.ts, apps/studio/data/projects/projects-infinite-query.ts, apps/studio/data/service-status/service-status-query.ts, apps/studio/data/config/project-storage-config-query.ts, apps/studio/components/layouts/AppLayout/useStatusPageBannerVisibility.ts
Branches, projects, and service-status queries return a shared EMPTY_ARR when responses aren't arrays; pagination and feature flag reads use optional chaining to avoid errors on missing fields.
Logs explorer query param normalization
apps/studio/pages/project/[ref]/logs/explorer/index.tsx
The q route parameter is normalized to a single string when useParams returns an array.
Feature flag provider proxy guard
packages/common/feature-flags.tsx
userEmail derivation checks __isUserNotAvailableProxy before accessing session user fields, returning undefined when user data isn't available.

Estimated code review effort: 2 (Simple) | ~15 minutes

Suggested reviewers: ivasilov

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: a batch of Studio Sentry crash fixes.
Description check ✅ Passed The description covers the change type, linked issue, affected bugs, and test plan, though it doesn't follow the template headings exactly.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch aliwaseem/fe-3862-fix-batch-of-production-sentry-crashes-arraynull-guards

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  231 passed
flaky  1 flaky
skipped  5 skipped

Details

stats  237 tests across 27 suites
duration  4 minutes, 27 seconds
commit  a6f52a4

Flaky tests

Features › sql-editor.spec.ts › SQL Editor › should check if SQL editor is working as expected

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

})

const formattedViews = views.map((x) => {
const formattedViews = (Array.isArray(views) ? views : []).map((x) => {

@joshenlim joshenlim Jul 8, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

these patches are alright for now, but im actually just wondering whether this guard should be at the react query level (looks a bit hacky otherwise, cause we're already trying to guard with default values + the data from the react query is expected to be an array if the request is successful)

trying to figure out when views (or the other ones) will return as a non-array too - we're currently using the pg-meta endpoints for views and materialized views so perhaps the next step is to refactor them to use direct SQL instead for better control

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

stack traces point to views (and i'd assume materialized views as well) - so perhaps tables and foreign tables (both using raw SQL) are alright

Image

Comment on lines +376 to +381
export const parseSelectedDate = (value?: string | null): Date | null => {
if (!value) return null
const parsed = dayjs(value)
return parsed.isValid() ? parsed.toDate() : null
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is just a thought but im wondering if we can merge this with resolveLogTimestamp given how similar they are

perhaps the API could be resolveLogTimestamp({ value?: string, defaultToNull: boolean })

(q) => q.isError || (q.data !== undefined && q.data.pagination.count > q.data.projects.length)
(q) =>
q.isError ||
(q.data !== undefined && (q.data.pagination?.count ?? 0) > q.data.projects.length)

@joshenlim joshenlim Jul 8, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i'm just wondering when pagination would be undefined though if data is not undefined (which would imply that the data was successfully retrieved)

at least from an API response types POV - pagination is expected from the response

}

return data
return Array.isArray(data) ? data : EMPTY_ARR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this also seems like a patch but it's probably worth also checking why data is not getting returned as an array from the API - the API types expect that data should be an array

@joshenlim joshenlim Jul 8, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the error is from here which imo would only happen if this request is successfully but data is somehow not an array (which is unexpected)

export const useIsAnalyticsBucketsEnabled = ({ projectRef }: { projectRef?: string }) => {
const { data } = useProjectStorageConfigQuery({ projectRef })
const isIcebergCatalogEnabled = !!data?.features.icebergCatalog?.enabled
const isIcebergCatalogEnabled = !!data?.features?.icebergCatalog?.enabled

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hmm likewise - the API types expect features to be present in data
so i'm wondering if for this case specifically, there's some projects that somehow don't have the features property in their storage config (and if so should be enforced via API types)

@awaseem awaseem closed this Jul 8, 2026
@joshenlim joshenlim mentioned this pull request Jul 8, 2026
joshenlim added a commit that referenced this pull request Jul 8, 2026
## Context

Just extracting the fixes which I think are applicable from this
[PR](#47695)

Main files are
- `apps/studio/hooks/analytics/useLogsQuery.tsx`
- `packages/common/auth.tsx`
- `packages/common/feature-flags.tsx`

## Changes involved
- Adjust `useLogsQuery` to accept an object as prop, rather than 4
individual params
- This one doesn't address any Sentry issues, but is just a improvement
to the function's API imo, more readable
- Adjust how user email is retrieved in `feature-flags`
- Related Sentry issue
[here](https://supabase.sentry.io/issues/7592718607/?project=5459134)
- The error is a bit vague, but Claude's attempt to fix looks alright in
general IMO
  - Minimally verified that feature flags are loading as expected still

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved log-related screens and queries for more reliable loading and
filtering across the app.
* Fixed profile and account data handling so identity details are
retrieved more consistently.
* Improved authentication handling to better recognize missing user data
and keep the app stable.
* Updated feature flag personalization to use more accurate account
information.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

2 participants