nautechsystems/nautilus_trader · error
Unsupported operation: `insert` for collection '{collection}
Error message
Unsupported operation: `insert` for collection '{collection}' What it means
The Redis cache insert path dispatches on the collection parsed from the key; only recognized collections (candles? plus ACCOUNTS | ORDERS | POSITIONS | SNAPSHOTS, etc.) have insert implementations, and the final `_` arm bails with "Unsupported operation: `insert` for collection '<name>'". The key's collection is not an insertable type.
Source
Thrown at crates/infrastructure/src/redis/cache.rs:957
Ok(())
}
fn insert(pipe: &mut Pipeline, collection: &str, key: &str, value: &[Bytes]) -> anyhow::Result<()> {
check_slice_not_empty(value, stringify!(value))?;
match collection {
INDEX => insert_index(pipe, key, value),
GENERAL | CURRENCIES | INSTRUMENTS | INSTRUMENT_CLOSES | SYNTHETICS | ACTORS
| STRATEGIES | HEALTH | CUSTOM => {
insert_string(pipe, key, value[0].as_ref());
Ok(())
}
ACCOUNTS | ORDERS | POSITIONS | SNAPSHOTS => {
insert_list(pipe, key, value[0].as_ref());
Ok(())
}
_ => anyhow::bail!("Unsupported operation: `insert` for collection '{collection}'"),
}
}
fn insert_index(pipe: &mut Pipeline, key: &str, value: &[Bytes]) -> anyhow::Result<()> {
let index_key = get_index_key(key)?;
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 => {
insert_set(pipe, key, value[0].as_ref());
Ok(())
}View on GitHub (pinned to 18893faf8b)
Solutions
- Use a key with a supported collection prefix (ACCOUNTS, ORDERS, POSITIONS, SNAPSHOTS, or other implemented insertable collections).
- If inserting custom data, use the intended add_custom_data key format rather than a raw custom key.
- Add an insert arm for the new collection in the dispatch match if support must be extended.
Example fix
// before
cache.insert("mydata:123".into(), Some(payload))?; // unsupported collection
// after
cache.insert("ORDERS:123".into(), Some(payload))?; Defensive patterns
Strategy: validation
Validate before calling
fn collection_of(key: &str) -> &str {
key.split(':').next().unwrap_or("")
}
const INSERTABLE: [&str; 4] = ["ACCOUNTS", "ORDERS", "POSITIONS", "SNAPSHOTS"];
fn can_insert(key: &str) -> bool { INSERTABLE.contains(&collection_of(key)) } Type guard
fn is_insertable_key(key: &str) -> bool {
matches!(key.split(':').next(), Some("ACCOUNTS" | "ORDERS" | "POSITIONS" | "SNAPSHOTS"))
} Prevention
- Build cache keys via helper functions that use known collection prefixes.
- Never hand-format cache keys in strategy code.
- When adding a collection, extend both the key parser and the insert dispatch match.
- Use add_custom_data for arbitrary payloads instead of inventing custom collections.
When it happens
Trigger: Calling insert (or py_insert / add_custom_data) with a key whose collection segment is unknown, e.g. a malformed key without the expected `<collection>:...` prefix, or a collection like custom/index-only data that only supports update/delete.
Common situations: Hand-crafting Redis cache keys with the wrong prefix; writing a new collection type and forgetting to add an insert arm; using insert for a collection that is only indexed or updated in place.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Failed to send to channel: {e}
- Unsupported operation: `replace_list` for collection '{colle
- Unsupported operation: `update` for collection '{collection}
- DataActor {} must be registered before calling `cache()` - t
- Order {client_order_id} not found
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/afa67bcb9697923b.
Report an issue: GitHub.