Skip to content

Listing page crashes with "Cannot read properties of undefined (reading 'map')" #2048

Description

@alanpeixinho

Description

On /tree, the app can render the route error boundary ("Something went wrong! / Show Error") with the error Cannot read properties of undefined (reading 'map').

The error originates in TopBarOriginSelect (dashboard/src/components/TopBar/TopBar.tsx). pageOrigins is derived from the origins query and only guards !originData, not the case where originData exists without checkout_origins/test_origins:

const pageOrigins = useMemo(() => {
  if (!originData) return [];
  return isHardwarePath ? originData.test_origins : originData.checkout_origins;
}, [originData, isHardwarePath]);
// ...
pageOrigins.map(...)

The origins query (useOrigins) uses staleTime: 2h and is persisted via PersistQueryClientProvider. When the persisted cache holds an origins entry whose shape lacks those fields, pageOrigins is undefined and .map throws.

Reproduction

Dev server uses sessionStorage (prod uses localStorage).

  1. Open /tree.
  2. In the browser console, seed an origins cache entry with a mismatched shape and reload:
sessionStorage.setItem('REACT_QUERY_OFFLINE_CACHE', JSON.stringify({
  buster: '', timestamp: Date.now(),
  clientState: { mutations: [], queries: [{
    queryKey: ['origins'], queryHash: '["origins"]',
    state: { data: ['maestro'], dataUpdatedAt: Date.now(), dataUpdateCount: 1,
      error: null, errorUpdateCount: 0, errorUpdatedAt: 0, fetchFailureCount: 0,
      fetchFailureReason: null, fetchMeta: null, isInvalidated: false,
      status: 'success', fetchStatus: 'idle' } }] },
}));
location.reload();
  1. /tree shows "Something went wrong! / Show Error"; expanding shows Cannot read properties of undefined (reading 'map').

Recover: sessionStorage.clear() (or localStorage.clear()) then reload.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions