BoundaryML/baml · warning · ExposedError

ExposedError::AbortError { detailed_message }

Error message

ExposedError::AbortError { detailed_message }

What it means

When the chain's LLMResponse is Cancelled, result_with_constraints_content converts it to ExposedError::AbortError with the cancellation detail message. This indicates the function execution was aborted (e.g. via a cancellation handle) rather than completing or failing.

Source

Thrown at engine/baml-runtime/src/types/response.rs:156

                            _ => Err(anyhow::anyhow!(
                                crate::errors::ExposedError::ClientHttpError {
                                    client_name: err.client.clone(),
                                    message: err.message.clone(),
                                    status_code: err.code.clone(),
                                    detailed_message: err.message.clone(),
                                    raw_response: err.raw_response.clone(),
                                }
                            )),
                        }
                    }
                    LLMResponse::UserFailure(message) => {
                        Err(anyhow::anyhow!("User Failure: {message}.\nPlease report this error to our team with BAML_LOG=info enabled so we can catch this error earlier and improve your development experience."))
                    }
                    LLMResponse::InternalFailure(message) => {
                        Err(anyhow::anyhow!("Internal Failure: {message}.\nThis should not happen - please report this error to our team with BAML_LOG=info enabled so we can catch this error earlier and improve your development experience."))
                    }
                    LLMResponse::Cancelled(message) => {
                        Err(anyhow::anyhow!(crate::errors::ExposedError::AbortError {
                            detailed_message: message.clone(),
                        }))
                    }
                    LLMResponse::Success(_) => {
                        Err(anyhow::anyhow!("This should never happen - Please report this error to our team with BAML_LOG=info enabled so we can improve this error message"))
                    }
                };
        };

        result
    }

    fn format_last_error_with_details(&self, last_error: &anyhow::Error) -> ExposedError {
        let detailed_message = self.create_detailed_message();

        if let Some(exposed_error) = last_error.downcast_ref::<ExposedError>() {
            return self.add_detailed_message_to_exposed(exposed_error.clone(), detailed_message);
        }

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Treat AbortError as an expected control-flow signal and handle it separately from real failures.
  2. Ensure callers do not read the result after cancelling the run.
  3. If cancellations are unexpected, audit which component aborts the future (proxy timeouts, request shutdown hooks).

Example fix

// before
let result = baml_fn.run(ctx).await?; // AbortError if cancelled

// after
match baml_fn.run(ctx).await {
    Ok(v) => Ok(v),
    Err(e) if is_abort_error(&e) => Ok(default_value), // cancelled by caller
    Err(e) => Err(e),
}
Defensive patterns

Strategy: try-catch

Try / catch

match run_result {
    Ok(v) => Ok(v),
    Err(e) if e.to_string().contains("AbortError") => Ok(default_value),
    Err(e) => Err(e),
}

Prevention

When it happens

Trigger: The LLM call/stream was cancelled — user-initiated abort via the runtime's cancellation API, dropped futures, or client disconnects — and the result is then read.

Common situations: Web request cancelled by the client while streaming; explicit .cancel() calls; timeouts in the host application that abort the BAML future mid-flight.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/dbffd7135e114f9f. Report an issue: GitHub.