BoundaryML/baml · critical · anyhow::Error

Internal Failure: . This should not happen - please report…

Error message

Internal Failure: {message}.
This 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.

What it means

When the chain's LLMResponse is InternalFailure, result_with_constraints_content raises an error stating this should never happen and asks the user to report it with BAML_LOG=info. It marks an internal BAML runtime failure — a bug or unexpected state, not a user error.

Solutions

  1. Re-run with BAML_LOG=info (or debug) and capture the trace.
  2. Update BAML runtime and generated code to matching versions.
  3. Report the issue to the BAML team with the log output, as the message instructs.
  4. As a workaround, catch the error and retry the function call.
Defensive patterns

Strategy: fallback

Try / catch

match chain.content() {
    Ok(v) => Ok(v),
    Err(e) if e.to_string().starts_with("Internal Failure:") => {
        report_bug_with_baml_log(&e);
        retry_or_default()
    }
    Err(e) => Err(e),
}

Prevention

When it happens

Trigger: The runtime recorded LLMResponse::InternalFailure (internal panics/invariant breaks during orchestration or streaming) and result_with_constraints_content is then called.

Common situations: BAML runtime bugs, corrupted streaming state, version incompatibilities between generated client code and the runtime.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

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

                            crate::internal::llm_client::ErrorCode::Other(2) => {
                                Err(anyhow::anyhow!(err.message.clone()))
                            }
                            _ => 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();

View on GitHub (pinned to bd85ce9dee)