Skip to main content
Last updated on

Error Handling

OpenBox decisions surface as runtime errors when execution cannot continue normally. This page covers the errors you should expect from the Mastra SDK and how to reason about them in production.

Startup Errors

Startup validation can fail before your service begins serving traffic.

Typical configuration errors:

ErrorCause
OpenBoxConfigErrorRequired configuration is missing or invalid
OpenBoxAuthErrorAPI key is missing, malformed, or rejected
OpenBoxInsecureURLErrorHTTP is used for a non-localhost OpenBox URL

What to do:

  1. Verify OPENBOX_URL and OPENBOX_API_KEY.
  2. Confirm the service can reach OpenBox Core.
  3. Use validate: false only for local mocks or tests.

Runtime Governance Errors

The SDK raises runtime errors when a verdict or approval state requires execution to stop or pause.

ErrorMeaning
GovernanceHaltErrorOpenBox returned a stop or halt-style verdict, or fail-closed converted an API failure into a halt
GuardrailsValidationErrorA guardrail validation failed
ApprovalPendingErrorApproval is still pending or inline polling timed out
ApprovalRejectedErrorA human reviewer rejected the request
ApprovalExpiredErrorApproval expired before a decision was made

How To Interpret Them

GovernanceHaltError

This is the main error when policy blocks or halts execution. Treat it as an intentional stop, not as a transport failure.

GuardrailsValidationError

This means the input or output violated a guardrail validation rule. If you are testing guardrails live, first confirm policy returned allow for that event.

Approval Errors

  • ApprovalPendingError means the decision is still unresolved.
  • ApprovalRejectedError means a human explicitly denied the action.
  • ApprovalExpiredError means the approval window closed without a final decision.

Failure Policy Matters

onApiError or OPENBOX_GOVERNANCE_POLICY changes runtime behavior during OpenBox outages:

SettingBehavior
fail_openExecution usually continues after retries are exhausted
fail_closedGoverned execution halts after retries are exhausted

If behavior seems unexpected, verify the effective config at startup.

  1. Treat governance errors as intentional business-control outcomes.
  2. Log the relevant workflow, run, and activity context.
  3. Do not swallow approval or halt errors silently.
  4. Keep your business fallback behavior explicit rather than implicit.