{"record":{"id":"38f86d90784bb954","repo":"BoundaryML/baml","slug":"aws-region-expected-please-set-env-v","errorCode":null,"errorMessage":"AWS region expected, please set: env.{v}","messagePattern":"AWS region expected, please set: env\\.(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs","lineNumber":656,"sourceCode":"                    None => None,\n                },\n                session_token: match &self.properties.session_token {\n                    Some(session_token) => {\n                        if session_token.starts_with(\"$\") {\n                            None\n                        } else {\n                            Some(session_token.clone())\n                        }\n                    }\n                    None => None,\n                },\n            }),\n        };\n\n        // Set region if specified\n        if let Some(aws_region) = self.properties.region.as_ref() {\n            if let Some(v) = aws_region.strip_prefix(\"$\") {\n                return Err(anyhow::anyhow!(\"AWS region expected, please set: env.{v}\",));\n            }\n\n            loader = loader.region(Region::new(aws_region.clone()));\n        }\n\n        let config = loader.load().await;\n        let http_client = custom_http_client::client()?;\n\n        let mut bedrock_config = aws_sdk_bedrockruntime::config::Builder::from(&config)\n            // To support HTTPS_PROXY https://github.com/awslabs/aws-sdk-rust/issues/169\n            .http_client(http_client)\n            // Adding a custom http client (above) breaks the stalled stream protection for some reason. If a bedrock request takes longer than 5s (the default grace period, it makes it error out), so we disable it.\n            .stalled_stream_protection(StalledStreamProtectionConfig::disabled())\n            .interceptor(CollectorInterceptor::new(\n                call_stack,\n                http_request_id.clone(),\n                &self.properties,\n            ));","sourceCodeStart":638,"sourceCodeEnd":674,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs#L638-L674","documentation":"When building the BedrockRuntimeClient, if the region property references an environment variable via the '$VAR' syntax, the client checks the value; if the region string still starts with '$' it means the env var was never substituted/set, so it errors with 'AWS region expected, please set: env.{v}'. This prevents sending a literal '$MY_REGION' as an AWS region.","triggerScenarios":"Client options contain region $AWS_REGION (or similar), and the referenced environment variable is undefined at runtime so the placeholder is passed through unresolved.","commonSituations":"Missing AWS_REGION in the shell/CI/container; .env file not loaded by the process; variable name typo between the client config and the actual env var.","solutions":["Set the referenced environment variable (e.g. export AWS_REGION=us-east-1) before running.","Verify the variable name after '$' matches exactly what is defined in your environment/.env.","Alternatively hardcode the region string in client options to avoid env substitution entirely."],"exampleFix":"// before\noptions { region $AWS_REGION }  // AWS_REGION unset\n// after\nexport AWS_REGION=us-east-1  # then run, or:\noptions { region us-east-1 }","handlingStrategy":"validation","validationCode":"import os\nvar = 'AWS_REGION'\nif f'${var}' in str(client_options.get('region', '')):\n    assert os.environ.get(var), f\"env {var} must be set for aws-bedrock region\"","typeGuard":null,"tryCatchPattern":"try:\n    resp = baml_client.MyFunction(...)\nexcept Exception as e:\n    if 'AWS region expected, please set' in str(e):\n        # missing env var referenced as $VAR in region option\n        raise RuntimeError('Set the AWS region env var or hardcode region in options') from e\n    raise","preventionTips":["Keep the '$VAR' name and the actual env var name in sync","Load .env files before initializing BAML clients","Prefer explicit region strings in committed config for reproducibility"],"tags":["aws","region","env-var","config","bedrock"],"backgroundTag":"missing-env-var","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}