{"record":{"id":"afa67bcb9697923b","repo":"nautechsystems/nautilus_trader","slug":"unsupported-operation-insert-for-collection-c","errorCode":null,"errorMessage":"Unsupported operation: `insert` for collection '{collection}'","messagePattern":"Unsupported operation: `insert` for collection '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/redis/cache.rs","lineNumber":957,"sourceCode":"\n    Ok(())\n}\n\nfn insert(pipe: &mut Pipeline, collection: &str, key: &str, value: &[Bytes]) -> anyhow::Result<()> {\n    check_slice_not_empty(value, stringify!(value))?;\n\n    match collection {\n        INDEX => insert_index(pipe, key, value),\n        GENERAL | CURRENCIES | INSTRUMENTS | INSTRUMENT_CLOSES | SYNTHETICS | ACTORS\n        | STRATEGIES | HEALTH | CUSTOM => {\n            insert_string(pipe, key, value[0].as_ref());\n            Ok(())\n        }\n        ACCOUNTS | ORDERS | POSITIONS | SNAPSHOTS => {\n            insert_list(pipe, key, value[0].as_ref());\n            Ok(())\n        }\n        _ => anyhow::bail!(\"Unsupported operation: `insert` for collection '{collection}'\"),\n    }\n}\n\nfn insert_index(pipe: &mut Pipeline, key: &str, value: &[Bytes]) -> anyhow::Result<()> {\n    let index_key = get_index_key(key)?;\n    match index_key {\n        INDEX_ORDER_IDS\n        | INDEX_ORDERS\n        | INDEX_ORDERS_OPEN\n        | INDEX_ORDERS_CLOSED\n        | INDEX_ORDERS_EMULATED\n        | INDEX_ORDERS_INFLIGHT\n        | INDEX_POSITIONS\n        | INDEX_POSITIONS_OPEN\n        | INDEX_POSITIONS_CLOSED => {\n            insert_set(pipe, key, value[0].as_ref());\n            Ok(())\n        }","sourceCodeStart":939,"sourceCodeEnd":975,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/redis/cache.rs#L939-L975","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ncache.insert(\"mydata:123\".into(), Some(payload))?; // unsupported collection\n// after\ncache.insert(\"ORDERS:123\".into(), Some(payload))?;","handlingStrategy":"validation","validationCode":"fn collection_of(key: &str) -> &str {\n    key.split(':').next().unwrap_or(\"\")\n}\nconst INSERTABLE: [&str; 4] = [\"ACCOUNTS\", \"ORDERS\", \"POSITIONS\", \"SNAPSHOTS\"];\nfn can_insert(key: &str) -> bool { INSERTABLE.contains(&collection_of(key)) }","typeGuard":"fn is_insertable_key(key: &str) -> bool {\n    matches!(key.split(':').next(), Some(\"ACCOUNTS\" | \"ORDERS\" | \"POSITIONS\" | \"SNAPSHOTS\"))\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["redis","cache","collection","unsupported","rust"],"backgroundTag":"unsupported-operation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}