BoundaryML/baml · error

region must be provided

Error message

region must be provided

What it means

In wasm32 builds of the AWS Bedrock client, resolve() requires an explicit region because there is no ambient AWS configuration chain in the browser/JS runtime to infer one from. If region is None after config and env-var fallbacks, this error is thrown.

Solutions

  1. Add an explicit `region` option to the aws-bedrock client config.
  2. When embedding in JS/WASM, inject the region into the evaluation context env vars before resolving.
  3. Verify you are not relying on ~/.aws/config defaults, which are unavailable under wasm32.

Example fix

// before
options {
  model "anthropic.claude-3-sonnet-20240229-v1:0"
}
// after
options {
  model "anthropic.claude-3-sonnet-20240229-v1:0"
  region "us-east-1"
}
Defensive patterns

Strategy: validation

Validate before calling

// wasm build: ensure region injected before resolve
let ctx = EvaluationContext::new();
ctx.env.insert("AWS_REGION".into(), js_region.into());

Prevention

When it happens

Trigger: Running a BAML wasm (browser/WASM runtime) call with an aws-bedrock client that has no `region` option and no AWS_REGION/AWS_DEFAULT_REGION env vars available.

Common situations: Using BAML from a browser or WASM-bound environment where the local machine's AWS config file is inaccessible; forgetting that env-var fallback does not exist in wasm.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

Thrown at engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:397

            },
        };

        let endpoint_url = match self.endpoint_url.as_ref() {
            Some(endpoint_url) => {
                let url = endpoint_url.resolve(ctx)?;
                if url.is_empty() {
                    None
                } else {
                    Some(url)
                }
            }
            None => None,
        };

        #[cfg(target_arch = "wasm32")]
        {
            if region.is_none() {
                return Err(anyhow::anyhow!("region must be provided"));
            }
        }

        let additional_model_request_fields = self
            .additional_model_request_fields
            .iter()
            .map(|(k, (_, v))| Ok((k.clone(), v.resolve_serde::<serde_json::Value>(ctx)?)))
            .collect::<Result<IndexMap<_, _>>>()?;

        Ok(ResolvedAwsBedrock {
            model: model.resolve(ctx)?,
            region,
            access_key_id,
            secret_access_key,
            session_token,
            profile,
            endpoint_url,
            role_selection,

View on GitHub (pinned to bd85ce9dee)