Skip to content

[BUG] Activity registry returns undefined for unknown IDs instead of throwing, causing silent TypeError downstream #1360

Description

@anshul23102

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

  1. Navigate to /activities/nonexistent-id in the running app.
  2. Observe the component crashes with TypeError: Cannot read properties of undefined (reading 'title').
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions