{"record":{"id":"8605a2b798d6c05e","repo":"mastra-ai/mastra","slug":"aborted-by-processor","errorCode":null,"errorMessage":"Aborted by processor","messagePattern":"Aborted by processor","errorType":"exception","errorClass":"TripWire","httpStatus":null,"severity":"warning","filePath":"client-sdks/ai-sdk/src/middleware.ts","lineNumber":505,"sourceCode":"          messageList.add(msg, 'input');\n        }\n      }\n\n      const originalInputCount = params.prompt.filter(msg => msg.role !== 'system').length;\n\n      // Run each input processor\n      for (const processor of inputProcessors) {\n        if (processor.processInput) {\n          try {\n            // Processors modify messageList in place. Array returns are supported\n            // but the messageList reference takes precedence for preserving source info.\n            await processor.processInput({\n              messages: messageList.get.input.db(),\n              systemMessages: messageList.getSystemMessages(),\n              messageList,\n              requestContext,\n              abort: (reason?: string): never => {\n                throw new TripWire(reason || 'Aborted by processor');\n              },\n            } as ProcessInputArgs);\n          } catch (error) {\n            if (error instanceof TripWire) {\n              // Store tripwire in providerOptions for wrapGenerate/wrapStream to handle\n              return {\n                ...params,\n                providerOptions: {\n                  ...params.providerOptions,\n                  mastraProcessors: {\n                    tripwire: true,\n                    reason: error.message,\n                  } satisfies ProcessorMiddlewareState,\n                },\n              };\n            }\n            throw error;\n          }","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/client-sdks/ai-sdk/src/middleware.ts#L487-L523","documentation":"An input processor invoked a processor's processInput and the processor called abort(), which throws a TripWire. When no reason string is passed, the default message 'Aborted by processor' is used. The middleware catches the TripWire and stores it in providerOptions for wrapGenerate/wrapStream to surface as a controlled abort rather than a crash.","triggerScenarios":"A registered input processor decides the request must stop (e.g. moderation filter, secret scrubbing) and calls abort() without a custom reason string.","commonSituations":"Deploying guardrail/moderation processors that trip on sensitive content; users surprised that generation halted; assuming the message would include a custom reason but none was provided.","solutions":["Inspect the registered input processors to see which one tripped","Call abort('your reason') inside the processor to get a meaningful message","Adjust the processor's thresholds/rules if it trips incorrectly","Handle the TripWire result in wrapGenerate/wrapStream output (it surfaces as text/error content)"],"exampleFix":"// before\nabort();\n// after\nabort('Input blocked by moderation policy');","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"import { TripWire } from '@mastra/core';\ntry {\n  await processor.processInput({ ...args, abort: (r) => { throw new TripWire(r || 'Aborted by processor'); } });\n} catch (e) {\n  if (e instanceof TripWire) {\n    console.warn('Input aborted by processor:', e.message);\n    // surface a controlled response instead of failing hard\n  } else throw e;\n}","preventionTips":["Always pass a descriptive reason to abort() in processors","Log which processor aborted (wrap processInput with try/catch per processor)","Test moderation/guardrail processors against realistic inputs before deploy"],"tags":["processors","middleware","tripwire","aborted"],"backgroundTag":"processor-tripwire-abort","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}