{"record":{"id":"4bec1d5922f9d80c","repo":"mastra-ai/mastra","slug":"notification-inbox-search-requires-query","errorCode":null,"errorMessage":"notification-inbox search requires query","messagePattern":"notification-inbox search requires query","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/notifications/tool.ts","lineNumber":114,"sourceCode":"    execute: async (input: NotificationInboxAction, context) => {\n      const threadId = input.threadId ?? context?.agent?.threadId;\n      if (!threadId) {\n        throw new Error('notification-inbox requires a threadId');\n      }\n\n      if (input.action === 'list') {\n        const listInput: ListNotificationsInput = {\n          threadId,\n          status: input.status,\n          priority: input.priority,\n          source: input.source,\n          limit: input.limit,\n        };\n        return { notifications: await storage.listNotifications(listInput) };\n      }\n\n      if (input.action === 'search') {\n        if (!input.query) throw new Error('notification-inbox search requires query');\n        return {\n          notifications: await storage.listNotifications({\n            threadId,\n            search: input.query,\n            status: input.status,\n            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'],","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/notifications/tool.ts#L96-L132","documentation":"The search action of the notification-inbox tool requires a non-empty query string. Without it the tool would perform an unbounded listing, so the library throws to force the caller to specify what to search for.","triggerScenarios":"Invoking the tool with action 'search' but omitting input.query or passing an empty string (e.g. forwarding user input where the search box was blank).","commonSituations":"LLM-filled tool args where the model emitted action 'search' without query; UI passing empty search text straight to the tool instead of falling back to the 'list' action.","solutions":["Always supply a non-empty query when using action 'search'","Fall back to action 'list' when the query is empty","Validate user-supplied search input before mapping it to the tool action"],"exampleFix":"// before\nawait inboxTool.execute({ action: 'search', threadId, query: '' });\n// after\nconst action = query.trim() ? 'search' : 'list';\nawait inboxTool.execute({ action, threadId, ...(query.trim() ? { query: query.trim() } : {}) });","handlingStrategy":"validation","validationCode":"if (input.action === 'search' && !input.query?.trim()) {\n  input = { ...input, action: 'list' };\n}","typeGuard":"function isSearchAction(i: NotificationInboxAction): i is Extract<NotificationInboxAction, { action: 'search'; query: string }> {\n  return i.action === 'search' && typeof (i as any).query === 'string' && (i as any).query.length > 0;\n}","tryCatchPattern":"try {\n  return await inboxTool.execute(input, context);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('search requires query')) {\n    return await inboxTool.execute({ ...input, action: 'list' } as NotificationInboxAction, context);\n  }\n  throw e;\n}","preventionTips":["Map empty search boxes to the 'list' action in UI code","Validate query non-empty before calling the tool","Constrain the model with strict tool schema so query is emitted"],"tags":["notifications","tool","validation"],"backgroundTag":"missing-required-parameter","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}