{"record":{"id":"d8f8bdd7d27d7974","repo":"mastra-ai/mastra","slug":"tripwire-reason-processor-aborted","errorCode":null,"errorMessage":"TRIPWIRE:${reason || 'Processor aborted'}","messagePattern":"TRIPWIRE:(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"info","filePath":"packages/server/src/server/handlers/processors.ts","lineNumber":389,"sourceCode":"            throw error;\n          }\n          throw new HTTPException(500, {\n            message: `Error executing processor workflow: ${error.message}`,\n          });\n        }\n      }\n\n      // Handle individual processor execution\n      // Create the abort function for tripwire support\n      let tripwireTriggered = false;\n      let tripwireReason: string | undefined;\n      let tripwireMetadata: unknown;\n\n      const abort = (reason?: string, options?: { retry?: boolean; metadata?: unknown }) => {\n        tripwireTriggered = true;\n        tripwireReason = reason;\n        tripwireMetadata = options?.metadata;\n        throw new Error(`TRIPWIRE:${reason || 'Processor aborted'}`);\n      };\n\n      // Build the context based on phase\n      const baseContext = {\n        abort,\n        retryCount: 0,\n        messages: messageList.get.all.db(),\n        messageList,\n        state: {},\n      };\n\n      try {\n        let result: any;\n\n        // Execute the specific phase method on the individual processor\n        switch (phase) {\n          case 'input':\n            if (!processor.processInput) {","sourceCodeStart":371,"sourceCodeEnd":407,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/processors.ts#L371-L407","documentation":"This is the sentinel Error thrown by the `abort(reason?, options?)` function injected into a processor's execution context. It is not a real failure: the handler catches it, detects the `TRIPWIRE:` prefix (or the tripwireTriggered flag), and converts it into a `{ success: false, tripwire: { triggered: true, reason, metadata } }` response, mirroring Mastra's tripwire semantics for processors halting agent flow.","triggerScenarios":"Calling `context.abort('reason', { metadata })` (or `abort()` with no args) inside processInput/processOutputResult/etc. during POST /processors/:id/execute — the thrown `Error('TRIPWIRE:...')` propagates to the handler's catch block.","commonSituations":"A moderation/PII processor detects disallowed content and intentionally stops the run; a developer accidentally calls abort in normal control flow and is surprised execution stops; a custom processor aborts without a reason, producing the generic 'Processor aborted' message.","solutions":["Treat the tripwire response as expected behavior — check `result.tripwire.triggered` and `reason` in the response body instead of treating it as an error.","Always pass a descriptive reason to `abort()` so downstream consumers can act on it.","Use `options.metadata` to attach structured context (matched terms, scores) for programmatic handling.","If you see the raw `TRIPWIRE:` Error escaping to your own catch, you invoked the processor outside the server handler — replicate the handler's prefix check or use core's Tripwire handling."],"exampleFix":"// before\n} catch (e) {\n  console.error('Processor crashed:', e);\n}\n// after\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('TRIPWIRE:')) {\n    handleTripwire(e.message.replace('TRIPWIRE:', ''));\n  } else {\n    throw e;\n  }\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isTripwireError(e: unknown): e is Error & { tripwireReason?: string } {\n  return e instanceof Error && e.message.startsWith('TRIPWIRE:');\n}","tryCatchPattern":"try {\n  const result = await runProcessorPhase(id, phase, messages);\n  if (result.tripwire?.triggered) {\n    console.warn(`Processor aborted: ${result.tripwire.reason}`, result.tripwire.metadata);\n    return handleTripwire(result.tripwire);\n  }\n  return result;\n} catch (e) {\n  if (isTripwireError(e)) {\n    return handleTripwire({ reason: e.message.replace('TRIPWIRE:', '') });\n  }\n  throw e;\n}","preventionTips":["Always pass a meaningful reason and metadata to abort() for downstream handling.","Structure consumers to check the tripwire field in execute responses rather than treating success:false as a crash.","Only call abort() for genuine halts (moderation, policy) — not ordinary control flow.","If invoking processors outside the server handler, replicate the TRIPWIRE: prefix check or use core's tripwire utilities."],"tags":["mastra-server","processor","tripwire","abort","control-flow"],"backgroundTag":"processor-tripwire-abort","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}