mastra-ai/mastra · error

notification-inbox requires id

Error message

notification-inbox ${input.action} requires id

What it means

Actions markSeen, dismiss, and archive operate on a single notification and therefore require input.id. The tool throws this error when the action is one of these but no id was supplied.

Solutions

  1. Always include id in the tool input for markSeen/dismiss/archive actions
  2. Enforce the input schema (notificationActionSchema) at the UI/client layer before invoking the tool
  3. If the LLM omits id, re-prompt or reject the tool call; check tool choice/strict schema settings

Example fix

// before
await inboxTool.execute({ action: 'dismiss', threadId });
// after
await inboxTool.execute({ action: 'dismiss', threadId, id: notificationId });
Defensive patterns

Strategy: validation

Validate before calling

const idActions = ['markSeen', 'dismiss', 'archive'] as const;
if (idActions.includes(input.action as any) && !input.id) {
  throw new Error(`Action ${input.action} requires a notification id`);
}

Type guard

function hasId(i: NotificationInboxAction): i is NotificationInboxAction & { id: string } {
  return typeof (i as any).id === 'string' && (i as any).id.length > 0;
}

Try / catch

try {
  await inboxTool.execute(input, context);
} catch (e) {
  if (e instanceof Error && e.message.includes('requires id')) {
    logger.warn('Tool call missing id', { action: input.action });
    return { error: 'Select a notification first' };
  }
  throw e;
}

Prevention

When it happens

Trigger: Invoking the notification-inbox tool with action 'markSeen', 'dismiss', or 'archive' while omitting input.id — commonly when the LLM emits partial tool arguments or a UI button click sends an action without the selected notification id.

Common situations: Model-generated tool calls missing required fields despite the schema; frontend dispatching actions with stale/undefined state; writing tests against the tool with incomplete inputs.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/7641367085e44041. Report an issue: GitHub.

Appendix: source

Thrown at packages/core/src/notifications/tool.ts:148

          : await storage.listNotifications({
              threadId,
              status: input.status ?? ['pending', 'delivered'],
              priority: input.priority,
              source: input.source,
              limit: input.limit,
            });
        if (input.id && !notifications[0])
          throw new Error(`Notification ${input.id} was not found for thread ${threadId}`);
        return deliverNotifications({
          notifications: notifications.filter((notification): notification is NotificationRecord =>
            Boolean(notification),
          ),
          storage,
          context,
        });
      }

      if (!input.id) throw new Error(`notification-inbox ${input.action} requires id`);
      const statusByAction = {
        markSeen: 'seen',
        dismiss: 'dismissed',
        archive: 'archived',
      } satisfies Record<'markSeen' | 'dismiss' | 'archive', NotificationStatus>;

      return {
        notification: await storage.updateNotification({
          threadId,
          id: input.id,
          status: statusByAction[input.action],
        }),
      };
    },
  });
}

View on GitHub (pinned to 75dd419e61)