{"record":{"id":"89462df40e989f72","repo":"BoundaryML/baml","slug":"region-must-be-provided","errorCode":null,"errorMessage":"region must be provided","messagePattern":"region must be provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-lib/llm-client/src/clients/aws_bedrock.rs","lineNumber":397,"sourceCode":"            },\n        };\n\n        let endpoint_url = match self.endpoint_url.as_ref() {\n            Some(endpoint_url) => {\n                let url = endpoint_url.resolve(ctx)?;\n                if url.is_empty() {\n                    None\n                } else {\n                    Some(url)\n                }\n            }\n            None => None,\n        };\n\n        #[cfg(target_arch = \"wasm32\")]\n        {\n            if region.is_none() {\n                return Err(anyhow::anyhow!(\"region must be provided\"));\n            }\n        }\n\n        let additional_model_request_fields = self\n            .additional_model_request_fields\n            .iter()\n            .map(|(k, (_, v))| Ok((k.clone(), v.resolve_serde::<serde_json::Value>(ctx)?)))\n            .collect::<Result<IndexMap<_, _>>>()?;\n\n        Ok(ResolvedAwsBedrock {\n            model: model.resolve(ctx)?,\n            region,\n            access_key_id,\n            secret_access_key,\n            session_token,\n            profile,\n            endpoint_url,\n            role_selection,","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/llm-client/src/clients/aws_bedrock.rs#L379-L415","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add an explicit `region` option to the aws-bedrock client config.","When embedding in JS/WASM, inject the region into the evaluation context env vars before resolving.","Verify you are not relying on ~/.aws/config defaults, which are unavailable under wasm32."],"exampleFix":"// before\noptions {\n  model \"anthropic.claude-3-sonnet-20240229-v1:0\"\n}\n// after\noptions {\n  model \"anthropic.claude-3-sonnet-20240229-v1:0\"\n  region \"us-east-1\"\n}","handlingStrategy":"validation","validationCode":"// wasm build: ensure region injected before resolve\nlet ctx = EvaluationContext::new();\nctx.env.insert(\"AWS_REGION\".into(), js_region.into());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In browser/WASM environments always set region explicitly; do not rely on AWS config files.","Inject AWS_REGION into the runtime env when embedding BAML in JS.","Document required bedrock options (model + region) wherever wasm entry points are exposed."],"tags":["aws-bedrock","wasm","region"],"backgroundTag":"missing-required-config-field","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}