Description
src/registry/ (or src/data/activities/index.js) looks up activity definitions by ID using a plain object map. When a route is accessed with an unknown activity ID (e.g., a stale bookmark or a typo in a link), the lookup returns undefined. The consuming component then accesses undefined.title, throwing a TypeError that bubbles up uncaught and crashes the route.
Steps to Reproduce
- Navigate to
/activities/nonexistent-id in the running app.
- Observe the component crashes with
TypeError: Cannot read properties of undefined (reading 'title').
- Confirm no 404 or fallback page is rendered - just a blank or broken UI.
Root Cause
The registry lookup has no guard for missing keys, and the route component does not check for a null/undefined result before rendering.
Impact
Any stale or manually crafted URL with an invalid activity ID crashes the route silently instead of showing a user-friendly 404 page.
Proposed Fix
// src/registry/index.ts
export function getActivity(id: string) {
const activity = activityMap[id];
if (!activity) throw new Response("Not found", { status: 404 });
return activity;
}
Use React Router's errorElement on the route to render a 404 page when the loader throws.
Description
src/registry/(orsrc/data/activities/index.js) looks up activity definitions by ID using a plain object map. When a route is accessed with an unknown activity ID (e.g., a stale bookmark or a typo in a link), the lookup returnsundefined. The consuming component then accessesundefined.title, throwing aTypeErrorthat bubbles up uncaught and crashes the route.Steps to Reproduce
/activities/nonexistent-idin the running app.TypeError: Cannot read properties of undefined (reading 'title').Root Cause
The registry lookup has no guard for missing keys, and the route component does not check for a null/undefined result before rendering.
Impact
Any stale or manually crafted URL with an invalid activity ID crashes the route silently instead of showing a user-friendly 404 page.
Proposed Fix
Use React Router's
errorElementon the route to render a 404 page when the loader throws.