nautechsystems/nautilus_trader · error

Unknown Gamma market filter key '{key}'

Error message

Unknown Gamma market filter key '{key}'

What it means

build_gamma_params_from_hashmap only accepts a fixed allowlist of Gamma market filter keys. Any key outside that list is rejected instead of being passed to the Gamma API. This catches typos and stale filter names at call time.

Source

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

            | "volume_num_min"
            | "volume_num_max"
            | "start_date_min"
            | "start_date_max"
            | "end_date_min"
            | "end_date_max"
            | "tag_id"
            | "related_tags"
            | "tag_match"
            | "decimalized"
            | "cyom"
            | "rfq_enabled"
            | "uma_resolution_status"
            | "game_id"
            | "sports_market_types"
            | "include_tag"
            | "locale"
            | "max_markets" => {}
            _ => anyhow::bail!("Unknown Gamma market filter key '{key}'"),
        }
    }

    let mut params = GetGammaMarketsParams::default();

    if map
        .get("is_active")
        .map(|value| parse_gamma_filter_bool("market", "is_active", value))
        .transpose()?
        .unwrap_or(false)
    {
        params.active = Some(true);
        params.archived = Some(false);
        params.closed = Some(false);
    }

    if let Some(v) = map.get("active") {
        params.active = Some(parse_gamma_filter_bool("market", "active", v)?);

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Check the key spelling against the allowed market filter list (e.g. uma_resolution_status, game_id, sports_market_types, include_tag, locale, max_markets)
  2. Remove the unknown key from the filter map or move it to the events query if it is an event filter
  3. Regenerate the filter map from a typed params builder instead of a raw hashmap

Example fix

// before
let filters = hashmap!{"limit" => "10"}; // not a market key
provider.query_markets(filters).await?;
// after
let filters = hashmap!{"max_markets" => "10"};
provider.query_markets(filters).await?;
Defensive patterns

Strategy: validation

Validate before calling

const MARKET_KEYS: &[&str] = &["uma_resolution_status","game_id","sports_market_types","include_tag","locale","max_markets"];
for k in filters.keys() {
    assert!(MARKET_KEYS.contains(&k.as_str()), "unknown Gamma market filter: {k}");
}

Try / catch

match provider.query_markets(filters).await {
    Err(e) if e.to_string().contains("Unknown Gamma market filter") => {
        eprintln!("bad filter key: {e}"); // fix map and retry
    }
    r => r?,
}

Prevention

When it happens

Trigger: Passing a hashmap filter with an unrecognized key (e.g. 'market_slugz', a renamed key, or a key from the events API used in a markets query) to query_markets, fetch_bulk_instruments, or fetch_configured_instruments.

Common situations: Typos in filter keys; copying filters between markets and events APIs; following outdated documentation after the Gamma API changed parameter names.

Understand the failure class

Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.

Related errors


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