nautechsystems/nautilus_trader · error

Unsupported index operation: remove from '{index_key}'

Error message

Unsupported index operation: remove from '{index_key}'

What it means

delete_from_index handles removal from the two order-position index variants (INDEX_ORDER_POSITION, INDEX_ORDER_CLIENT) and, per the shown source, the set-based index arms above it. An index_key outside the recognized set falls to the wildcard arm and bails. This mirrors insert_index's exhaustiveness guard on the delete path.

Source

Thrown at crates/infrastructure/src/redis/cache.rs:1102

    match index_key {
        INDEX_ORDER_IDS
        | INDEX_ORDERS
        | INDEX_ORDERS_OPEN
        | INDEX_ORDERS_CLOSED
        | INDEX_ORDERS_EMULATED
        | INDEX_ORDERS_INFLIGHT
        | INDEX_POSITIONS
        | INDEX_POSITIONS_OPEN
        | INDEX_POSITIONS_CLOSED => {
            remove_from_set(pipe, key, value[0].as_ref());
            Ok(())
        }
        INDEX_ORDER_POSITION | INDEX_ORDER_CLIENT => {
            remove_from_hash(pipe, key, value[0].as_ref());
            Ok(())
        }
        _ => anyhow::bail!("Unsupported index operation: remove from '{index_key}'"),
    }
}

fn remove_from_set(pipe: &mut Pipeline, key: &str, member: &[u8]) {
    pipe.srem(key, member);
}

fn remove_from_hash(pipe: &mut Pipeline, key: &str, field: &[u8]) {
    pipe.hdel(key, field);
}

fn delete_string(pipe: &mut Pipeline, key: &str) {
    pipe.del(key);
}

fn full_redis_key(trader_key: &str, key: &str) -> String {
    format!("{trader_key}{REDIS_DELIMITER}{key}")
}

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Log the index_key on the delete path and compare against the INDEX_* constants used by insert_index.
  2. Use the same constants for insert and delete so both paths agree.
  3. Add the missing match arm in delete_from_index if a new index type must support removal.
  4. Sync crate versions between core and the redis adapter.

Example fix

// before
delete(pipe, INDEX, "order:idx_typo", value)?; // unknown index
// after
delete(pipe, INDEX, INDEX_ORDER_CLIENT, value)?;
Defensive patterns

Strategy: validation

Validate before calling

const DELETABLE_INDEXES: [&str; 2] = [INDEX_ORDER_POSITION, INDEX_ORDER_CLIENT];
assert!(DELETABLE_INDEXES.contains(&index_key), "cannot remove from index {index_key}");

Try / catch

// Python
try:
    cache.delete(INDEX, index_key, value)
except RuntimeError as e:
    if "Unsupported index operation" in str(e):
        log.warning("Index %s does not support removal", index_key)
    else:
        raise

Prevention

When it happens

Trigger: Calling delete with collection=INDEX and an index_key that is not one of the supported index constants (typo'd index name, custom index, or one added in a newer core version).

Common situations: Same version-skew and typo scenarios as the insert-side 'Index unknown' error: renamed index constants, forked custom indexes, or building index keys by string concatenation instead of using the constants.

Related errors


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