BoundaryML/baml · error

region cannot be empty

Error message

region cannot be empty

What it means

When a `region` is explicitly configured for an AWS Bedrock client, resolve() validates it is non-empty after resolving against the evaluation context. An empty string is rejected because AWS SDK calls cannot proceed without a region.

Solutions

  1. Set a literal region in the config, e.g. `region "us-east-1"`.
  2. Ensure AWS_REGION (or AWS_DEFAULT_REGION) is set and non-empty in the environment.
  3. Remove the explicit `region` field entirely and rely on env vars AWS_REGION/AWS_DEFAULT_REGION.

Example fix

// before
options {
  region "${AWS_REGION}"
}
// after
options {
  region "us-west-2"
}
Defensive patterns

Strategy: validation

Validate before calling

if let Some(r) = &cfg.region { if r.is_empty() { eprintln!("region configured but empty; set AWS_REGION or a literal value"); } }

Prevention

When it happens

Trigger: Setting `region` to a value that resolves to an empty string (e.g. an env-var expression pointing at AWS_REGION which is unset/empty, passed as `region "${AWS_REGION}"`).

Common situations: CI/CD environments where AWS_REGION is not exported; shell interpolation swallowing a variable; copy-pasting a config with `region ""` placeholder.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

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

        env_vars.extend(self.supported_request_modes.required_env_vars());
        if let Some(c) = self.inference_config.as_ref() {
            env_vars.extend(c.required_env_vars())
        }
        env_vars
    }

    pub fn resolve(&self, ctx: &EvaluationContext<'_>) -> Result<ResolvedAwsBedrock> {
        let Some(model) = self.model.as_ref() else {
            return Err(anyhow::anyhow!("model must be provided"));
        };

        let role_selection = self.role_selection.resolve(ctx)?;

        let region = match self.region.as_ref() {
            Some(region) => {
                let region = region.resolve(ctx)?;
                if region.is_empty() {
                    return Err(anyhow::anyhow!("region cannot be empty"));
                }
                Some(region)
            }
            None => match ctx.get_env_var("AWS_REGION") {
                Ok(region) if !region.is_empty() => Some(region),
                _ => match ctx.get_env_var("AWS_DEFAULT_REGION") {
                    Ok(region) if !region.is_empty() => Some(region),
                    _ => None,
                },
            },
        };

        let access_key_id = match self.access_key_id.as_ref() {
            Some(access_key_id) => Some(access_key_id.resolve(ctx)?),
            None => None,
        };

        let secret_access_key = self

View on GitHub (pinned to bd85ce9dee)