{"record":{"id":"05d816596ac621bb","repo":"mastra-ai/mastra","slug":"noise-example-queries-require-a-trace-signal-and-s","errorCode":null,"errorMessage":"Noise example queries require a trace signal and snapshot","messagePattern":"Noise example queries require a trace signal and snapshot","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playground-ui/src/ee/signals/hooks/use-noise-examples.ts","lineNumber":33,"sourceCode":"  filterThemes: ThemeSelection[] = [],\n) {\n  const { cacheScope, request } = useTraceIntelligence();\n  const serializedFilters = serializeThemeFilters(filterThemes);\n  return useQuery({\n    queryKey: [\n      'entity-learning',\n      cacheScope,\n      entityType,\n      entityId,\n      'noise-examples',\n      signalName,\n      snapshotId,\n      limit,\n      offset,\n      serializedFilters,\n    ],\n    queryFn: () => {\n      if (!signalName || !snapshotId) throw new Error('Noise example queries require a trace signal and snapshot');\n      return fetchNoiseExamples(request, entityId, entityType, signalName, snapshotId, limit, offset, filterThemes);\n    },\n    enabled: signalName !== undefined && snapshotId !== undefined,\n  });\n}\n","sourceCodeStart":15,"sourceCodeEnd":39,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/playground-ui/src/ee/signals/hooks/use-noise-examples.ts#L15-L39","documentation":"useNoiseExamples builds a React Query for noise examples tied to a trace signal and theme snapshot. Its queryFn re-validates inputs with this error even though the query has enabled: signalName !== undefined && snapshotId !== undefined — the throw is a defensive invariant that should never fire in normal operation, protecting against the query being force-run (e.g., refetch) with undefined inputs.","triggerScenarios":"Manually calling queryClient refetch/fetchQuery for the 'noise examples' key while signalName or snapshotId is undefined; calling the hook with enabled overridden; a race where signal selection is cleared while a refetch is in flight.","commonSituations":"Imperative refetch after clearing the selected signal; combining signal filters with snapshot resets; tests invoking the query function directly without fixtures.","solutions":["Ensure both signalName and snapshotId are defined before triggering the query or any manual refetch.","Keep the query disabled (enabled: signalName !== undefined && snapshotId !== undefined) and avoid overriding it.","Re-select a signal and snapshot after entity/filter changes before refetching.","If refetching imperatively, guard the call: only refetch when both parameters are present."],"exampleFix":"// before\nqueryClient.refetchQueries({ queryKey: ['noise-examples'] }); // can run with undefined inputs\n\n// after\nif (signalName && snapshotId) {\n  queryClient.refetchQueries({ queryKey: ['noise-examples', cacheScope, entityType, entityId, signalName, snapshotId] });\n}","handlingStrategy":"validation","validationCode":"const canFetch = signalName !== undefined && snapshotId !== undefined;\nif (canFetch) {\n  queryClient.refetchQueries({ queryKey: ['noise-examples', cacheScope, entityType, entityId, signalName, snapshotId] });\n}","typeGuard":"const hasNoiseInputs = (\n  s: string | undefined,\n  snap: string | undefined\n): s is string => s !== undefined && snap !== undefined;","tryCatchPattern":"try {\n  const data = await queryClient.fetchQuery({ queryKey, queryFn });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('trace signal and snapshot')) {\n    // inputs missing: re-select signal/snapshot instead of retrying\n  }\n}","preventionTips":["Never override the hook's enabled gate that requires signalName and snapshotId.","Include concrete signalName/snapshotId in query keys used for invalidation/refetch.","Guard imperative refetches with parameter checks.","Treat the throw as a bug signal — audit code paths that can run queryFn with undefined inputs."],"tags":["validation","react-query","signals","defensive-check"],"backgroundTag":"missing-required-parameter","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}