zeroclaw-labs/zeroclaw · error

cloud_ops.cost_threshold_monthly_usd must be non-negative, g

Error message

cloud_ops.cost_threshold_monthly_usd must be non-negative, got {}

What it means

`cloud_ops.cost_threshold_monthly_usd` flags cost items above a monthly USD threshold (default 100.0). A negative threshold is meaningless as a flagging bound — everything would be flagged or the comparison inverted — so validation requires it to be non-negative when the module is enabled.

Source

Thrown at crates/zeroclaw-config/src/schema.rs:18594

            }
            for (i, cloud) in self.supported_clouds.iter().enumerate() {
                if cloud.trim().is_empty() {
                    validation_bail!(
                        RequiredFieldEmpty,
                        format!("cloud_ops.supported_clouds[{i}]"),
                        "cloud_ops.supported_clouds[{i}] must not be empty"
                    );
                }
            }
            if !self.supported_clouds.contains(&self.default_cloud) {
                anyhow::bail!(
                    "cloud_ops.default_cloud '{}' is not in cloud_ops.supported_clouds {:?}",
                    self.default_cloud,
                    self.supported_clouds
                );
            }
            if self.cost_threshold_monthly_usd < 0.0 {
                anyhow::bail!(
                    "cloud_ops.cost_threshold_monthly_usd must be non-negative, got {}",
                    self.cost_threshold_monthly_usd
                );
            }
            if self.iac_tools.is_empty() {
                anyhow::bail!("cloud_ops.iac_tools must not be empty when cloud_ops is enabled");
            }
        }
        Ok(())
    }
}

fn default_cloud_ops_cloud() -> String {
    "aws".into()
}

fn default_cloud_ops_supported_clouds() -> Vec<String> {
    vec!["aws".into(), "azure".into(), "gcp".into()]

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Set a non-negative value, e.g. the default `100.0`.
  2. If the intent was 'no threshold', use a very large positive value rather than a negative one.
  3. Re-check the number's source if it is computed.

Example fix

# before
cost_threshold_monthly_usd = -1.0

# after
cost_threshold_monthly_usd = 100.0
Defensive patterns

Strategy: validation

Validate before calling

anyhow::ensure!(
    !cloud_ops.enabled || cloud_ops.cost_threshold_monthly_usd >= 0.0,
    "cost_threshold_monthly_usd must be non-negative"
);

Prevention

When it happens

Trigger: `cost_threshold_monthly_usd = -1.0` (or any negative) in an enabled `[cloud_ops]` block; arithmetic that computes a discount and subtracts past zero; a sentinel like `-1` meaning 'unlimited' carried over from another tool's convention.

Common situations: Porting sentinel-value conventions from other systems where -1 disables a limit; spreadsheet-derived budgets that go negative after refunds/credits; typos on the minus key.

Related errors


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/a044637643ef073c. Report an issue: GitHub.