{"record":{"id":"1b7f858c2525bb05","repo":"mastra-ai/mastra","slug":"notification-input-id-was-not-found-for-thread-1b7f85","errorCode":null,"errorMessage":"Notification ${input.id} was not found for thread ${threadId}","messagePattern":"Notification (.+?) was not found for thread (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/notifications/tool.ts","lineNumber":138,"sourceCode":"            priority: input.priority,\n            source: input.source,\n            limit: input.limit,\n          }),\n        };\n      }\n\n      if (input.action === 'read') {\n        const notifications = input.id\n          ? [await storage.getNotification({ threadId, id: input.id })]\n          : await storage.listNotifications({\n              threadId,\n              status: input.status ?? ['pending', 'delivered'],\n              priority: input.priority,\n              source: input.source,\n              limit: input.limit,\n            });\n        if (input.id && !notifications[0])\n          throw new Error(`Notification ${input.id} was not found for thread ${threadId}`);\n        return deliverNotifications({\n          notifications: notifications.filter((notification): notification is NotificationRecord =>\n            Boolean(notification),\n          ),\n          storage,\n          context,\n        });\n      }\n\n      if (!input.id) throw new Error(`notification-inbox ${input.action} requires id`);\n      const statusByAction = {\n        markSeen: 'seen',\n        dismiss: 'dismissed',\n        archive: 'archived',\n      } satisfies Record<'markSeen' | 'dismiss' | 'archive', NotificationStatus>;\n\n      return {\n        notification: await storage.updateNotification({","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/notifications/tool.ts#L120-L156","documentation":"The deliver action resolves notifications from the thread and, if an explicit input.id was requested but no matching notification is returned, throws this error. It ensures a targeted delivery request fails loudly rather than silently delivering nothing or the wrong batch.","triggerScenarios":"Calling the tool with action 'deliver' and an id that does not exist in the thread, has been dismissed/archived (filtered by the status filter ['pending','delivered']), or was persisted under a different threadId.","commonSituations":"Stale notification ids after storage reset; trying to deliver an already-seen/dismissed notification while the status filter excludes it; cross-thread id reuse.","solutions":["Check the notification exists with the right status via listNotifications before delivering","Widen the status filter if the target notification may already be seen/dismissed","Confirm the id belongs to the same threadId","Handle the error and inform the user the notification no longer exists"],"exampleFix":"// before\nawait inboxTool.execute({ action: 'deliver', threadId, id: 'old-id' });\n// after\nconst [n] = await storage.listNotifications({ threadId, id: 'old-id' });\nif (n) await inboxTool.execute({ action: 'deliver', threadId, id: 'old-id' });","handlingStrategy":"validation","validationCode":"const [target] = await storage.listNotifications({ threadId, id, status: ['pending', 'delivered'] });\nif (!target) throw new Error(`Cannot deliver: notification ${id} not found or not deliverable`);","typeGuard":"function isDeliverable(n: NotificationRecord | undefined): n is NotificationRecord {\n  return Boolean(n && (n.status === 'pending' || n.status === 'delivered'));\n}","tryCatchPattern":"try {\n  await inboxTool.execute({ action: 'deliver', threadId, id }, context);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('was not found for thread')) {\n    logger.warn('Deliver target missing', { threadId, id });\n    return { delivered: 0 };\n  }\n  throw e;\n}","preventionTips":["Refresh notification state from storage before delivering","Check status filters include the notification's current status","Handle already-processed notifications gracefully in UI flows"],"tags":["notifications","tool","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}