{"record":{"id":"4a4b2fe8bf827575","repo":"mastra-ai/mastra","slug":"a-theme-snapshot-is-required","errorCode":null,"errorMessage":"A theme snapshot is required","messagePattern":"A theme snapshot is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playground-ui/src/ee/signals/hooks/theme-query-guards.ts","lineNumber":11,"sourceCode":"export function isNumericThemeId(themeId: string | undefined): themeId is string {\n  return themeId !== undefined && /^\\d+$/.test(themeId);\n}\n\nexport function requireNumericThemeId(themeId: string | undefined) {\n  if (!isNumericThemeId(themeId)) throw new Error('A numeric theme id is required');\n  return themeId;\n}\n\nexport function requireSnapshotId(snapshotId: string | undefined) {\n  if (!snapshotId) throw new Error('A theme snapshot is required');\n  return snapshotId;\n}\n","sourceCodeStart":1,"sourceCodeEnd":14,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/playground-ui/src/ee/signals/hooks/theme-query-guards.ts#L1-L14","documentation":"requireSnapshotId ensures a theme snapshot id is present before a theme query executes. Snapshot-dependent hooks (useThemeDetail, useThemeExamples, useThemePaths) call it because the API needs a specific snapshot to fetch against; when snapshotId is undefined or empty (typically because no snapshot has been selected or loaded yet), the guard throws this error.","triggerScenarios":"Calling useThemeDetail/useThemeExamples/useThemePaths before a snapshot is chosen; snapshot list query still loading so snapshotId is undefined; a user landing directly on a theme page with no snapshot in the URL or store.","commonSituations":"First page load before snapshot selection; clearing snapshot state on entity change; deep links missing the snapshot parameter; races between snapshot fetch and dependent queries.","solutions":["Gate the query with enabled: snapshotId !== undefined so queryFn never runs without a snapshot.","Select a default snapshot before rendering the dependent hooks.","Await/loading-gate the snapshot list query and render a loading state until a snapshotId exists.","Persist the snapshot id in the URL/store so deep links always provide one."],"exampleFix":"// before\nuseThemeExamples({ themeId, snapshotId }); // throws when snapshotId undefined\n\n// after\nconst ready = themeId !== undefined && snapshotId !== undefined;\nreturn ready ? useThemeExamples({ themeId, snapshotId }) : { data: undefined, isLoading: true };","handlingStrategy":"validation","validationCode":"if (!snapshotId) {\n  return <SnapshotPicker />; // don't run snapshot-dependent hooks yet\n}\nconst id = requireSnapshotId(snapshotId); // safe","typeGuard":"function hasSnapshotId(snapshotId: string | undefined): snapshotId is string {\n  return typeof snapshotId === 'string' && snapshotId.length > 0;\n}","tryCatchPattern":"try {\n  const id = requireSnapshotId(maybeSnapshotId);\n  // fetch with id\n} catch {\n  // prompt the user to select a snapshot\n}","preventionTips":["Set enabled: snapshotId !== undefined on snapshot-dependent queries.","Select a default snapshot on page load and persist it in the URL/store.","Show a snapshot-selection UI instead of mounting dependent hooks early.","Reset dependent state atomically when the snapshot changes."],"tags":["validation","query-parameters","react-query","signals"],"backgroundTag":"missing-required-parameter","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}