nautechsystems/nautilus_trader · error

Gamma {scope} filter '{key}' must be true or false, was '{va

Error message

Gamma {scope} filter '{key}' must be true or false, was '{value}'

What it means

Certain Gamma filters (e.g. boolean flags like include_tag-style options) must be the string 'true' or 'false' (case-insensitive). parse_gamma_filter_bool raises this error for any other value, since the Gamma API expects strict booleans.

Source

Thrown at crates/adapters/polymarket/src/providers.rs:975

    set_decimal!(volume_min);
    set_decimal!(volume_max);
    set_u32!(event_week);
    set_u32!(limit);
    set_u32!(offset);
    set_u32!(max_events);
    set_u64!(parent_event_id);

    params.validate_keyset().map_err(anyhow::Error::msg)?;
    Ok(params)
}

fn parse_gamma_filter_bool(scope: &str, key: &str, value: &str) -> anyhow::Result<bool> {
    if value.eq_ignore_ascii_case("true") {
        Ok(true)
    } else if value.eq_ignore_ascii_case("false") {
        Ok(false)
    } else {
        anyhow::bail!("Gamma {scope} filter '{key}' must be true or false, was '{value}'")
    }
}

fn parse_gamma_filter_u32(scope: &str, key: &str, value: &str) -> anyhow::Result<u32> {
    value.parse::<u32>().map_err(|e| {
        anyhow::anyhow!("Gamma {scope} filter '{key}' must be an unsigned integer: {e}")
    })
}

fn parse_gamma_filter_u64(scope: &str, key: &str, value: &str) -> anyhow::Result<u64> {
    value.parse::<u64>().map_err(|e| {
        anyhow::anyhow!("Gamma {scope} filter '{key}' must be an unsigned integer: {e}")
    })
}

fn parse_gamma_filter_decimal(scope: &str, key: &str, value: &str) -> anyhow::Result<Decimal> {
    parse_decimal_exact(value)
        .map_err(|e| anyhow::anyhow!("Gamma {scope} filter '{key}' must be a decimal number: {e}"))

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Change the value to exactly 'true' or 'false' (any case is accepted)
  2. Normalize the input: parse it as a bool in the caller (parse::<bool> or a config bool) and stringify as 'true'/'false'
  3. If the source uses 1/0 or yes/no, map those explicitly before passing

Example fix

// before
filters.insert("active".into(), "1".into());
// after
filters.insert("active".into(), "true".into());
Defensive patterns

Strategy: validation

Validate before calling

fn as_gamma_bool(v: &str) -> Option<&str> {
    match v.to_ascii_lowercase().as_str() {
        "true" => Some("true"),
        "false" => Some("false"),
        _ => None,
    }
}

Type guard

fn is_gamma_bool(v: &str) -> bool {
    v.eq_ignore_ascii_case("true") || v.eq_ignore_ascii_case("false")
}

Prevention

When it happens

Trigger: Supplying values like 'yes', '1', 'TRUE ', 'on', or an empty string for a boolean filter key in a markets or events filter map.

Common situations: Reading filter values from env vars or config files where '1'/'0' or 'yes'/'no' conventions are used; user-supplied query strings; YAML/TOML booleans stringified inconsistently.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/ef73917ebc73b952. Report an issue: GitHub.