BoundaryML/baml · error · RuntimeCallbackError

BAML internal error - credential provider bridges not initia

Error message

BAML internal error - credential provider bridges not initialized

What it means

RuntimeCallbackError::NoCredProviderBridge is returned by `get_js_callback_provider` (js_callback_provider.rs:48-52) when the `JS_CALLBACK_PROVIDER_SINGLETON` OnceLock has not been initialized via `set_js_callback_provider`. It signals that the Rust runtime tried to fetch AWS/GCP credentials through the JS callback bridge, but no bridge was ever registered - an initialization-order/lifecycle problem in the WASM host.

Source

Thrown at engine/baml-runtime/src/types/js_callback_provider.rs:38

}

#[derive(Debug, Error, Clone)]
/// For baml-src-reader and aws-cred-provider, provide a statically defined type which is Send + Sync
/// anyhow::Error is not Send + Sync, so it's convoluted to use it in this callback context
pub enum RuntimeCallbackError {
    #[error("Failed to send cred request across WASM bridge: {0}")]
    SendError(String),

    #[error("Failed to recv cred response across WASM bridge: {0}")]
    RecvError(String),

    #[error("Type error in JS callback: {0}")]
    JsCallbackTypeError(String),

    #[error("JS callback error: {name}: {message}")]
    JsCallbackRuntimeError { name: String, message: String },

    #[error("BAML internal error - credential provider bridges not initialized")]
    NoCredProviderBridge,
}

static_assertions::assert_impl_all!(RuntimeCallbackError: Send, Sync);

pub type RuntimeCallbackResult<T> = Result<T, RuntimeCallbackError>;

static JS_CALLBACK_PROVIDER_SINGLETON: OnceLock<JsCallbackProvider> = OnceLock::new();

pub fn get_js_callback_provider() -> Result<&'static JsCallbackProvider, RuntimeCallbackError> {
    JS_CALLBACK_PROVIDER_SINGLETON
        .get()
        .ok_or(RuntimeCallbackError::NoCredProviderBridge)
}

pub fn set_js_callback_provider(aws_cred_provider: JsCallbackProvider) {
    match JS_CALLBACK_PROVIDER_SINGLETON.set(aws_cred_provider) {
        Ok(_) => {

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Call the JS setup API that registers the credential provider bridge (which internally invokes set_js_callback_provider) before making any BAML function calls.
  2. Move the provider initialization to application startup, before instantiating/invoking BAML functions.
  3. Verify you are not creating a second runtime instance that lacks the singleton registration; the provider is process-global (OnceLock).
  4. If you don't need AWS/GCP bridged credentials, change the BAML provider config to use env/static credentials instead of the JS callback provider.

Example fix

// before
const result = await b.GenerateSummary(input); // NoCredProviderBridge

// after
await b.setupJsCallbackProvider({ awsCredentialProvider: defaultProvider() });
const result = await b.GenerateSummary(input);
Defensive patterns

Strategy: validation

Validate before calling

// ensure the bridge is registered before any BAML call
let bridgeReady = false;
export async function initBaml() {
  await b.setupJsCallbackProvider({ awsCredentialProvider: defaultProvider() });
  bridgeReady = true;
}
export function assertBamlReady() {
  if (!bridgeReady) throw new Error('Call initBaml() before any BAML function');
}

Prevention

When it happens

Trigger: Calling a BAML function whose AWS or GCP credential provider requires the JS bridge (aws_req/gcp_req) before the host called `set_js_callback_provider`; the OnceLock `.get()` returns None and `ok_or(RuntimeCallbackError::NoCredProviderBridge)` fires (js_callback_provider.rs:49-51).

Common situations: Using the WASM/Node build of BAML with an `aws-profile` or GCP auth BAML provider config but never calling the JS-side setup (e.g. `b.setupJsCallbackProvider`) at startup, or the setup running after the first LLM call, or a separate runtime instance missing the registration.

Related errors


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