nautechsystems/nautilus_trader · error

Unknown Gamma event filter key '{key}'

Error message

Unknown Gamma event filter key '{key}'

What it means

build_gamma_params_from_hashmap's event counterpart accepts only a fixed allowlist of Gamma event filter keys (end_date_min, tag_slug, order, limit, etc.). Any other key is rejected with this error. It prevents typos and event API keys leaking into requests.

Source

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

///
/// # Errors
///
/// Returns an error for unknown keys, malformed values, or invalid filter combinations.
pub fn build_gamma_event_params_from_hashmap(
    map: &HashMap<String, String>,
) -> anyhow::Result<GetGammaEventsParams> {
    for key in map.keys() {
        match key.as_str() {
            "is_active" | "active" | "closed" | "archived" | "id" | "slug" | "live"
            | "featured" | "cyom" | "title_search" | "liquidity_min" | "liquidity_max"
            | "volume_min" | "volume_max" | "start_date_min" | "start_date_max"
            | "end_date_min" | "end_date_max" | "start_time_min" | "start_time_max" | "tag_id"
            | "tag_slug" | "exclude_tag_id" | "related_tags" | "tag_match" | "series_id"
            | "game_id" | "event_date" | "event_week" | "featured_order" | "recurrence"
            | "created_by" | "parent_event_id" | "include_children" | "partner_slug"
            | "include_chat" | "include_template" | "include_best_lines" | "locale" | "order"
            | "ascending" | "limit" | "offset" | "max_events" => {}
            _ => anyhow::bail!("Unknown Gamma event filter key '{key}'"),
        }
    }

    let mut params = GetGammaEventsParams::default();

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

    macro_rules! set_bool {
        ($field:ident) => {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Verify the key against the event filter allowlist (end_date_min, start_date_min, tag_id, tag_slug, order, ascending, limit, offset, etc.)
  2. Correct or remove the offending key from the filter map
  3. Build filters with a typed struct or constants rather than free-form strings

Example fix

// before
let filters = hashmap!{"tagid" => "1"};
provider.query_events(filters).await?;
// after
let filters = hashmap!{"tag_id" => "1"};
provider.query_events(filters).await?;
Defensive patterns

Strategy: validation

Validate before calling

const EVENT_KEYS: &[&str] = &["end_date_min","end_date_max","tag_id","tag_slug","order","ascending","limit","offset","recurrence"];
for k in filters.keys() {
    assert!(EVENT_KEYS.contains(&k.as_str()), "unknown Gamma event filter: {k}");
}

Try / catch

match provider.query_events(filters).await {
    Err(e) if e.to_string().contains("Unknown Gamma event filter") => {
        eprintln!("bad event filter key: {e}");
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling query_events with a filter map containing a key not in the event allowlist, such as a market-only key or a misspelled parameter.

Common situations: Typos like 'tagid' instead of 'tag_id'; reusing market filter maps for event queries; using removed parameters from older Gamma API docs.

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/6c19cfa5e835987c. Report an issue: GitHub.