{"record":{"id":"63deb66695e8917f","repo":"nautechsystems/nautilus_trader","slug":"unsupported-operation-delete-for-collection-c","errorCode":null,"errorMessage":"Unsupported operation: `delete` for collection '{collection}'","messagePattern":"Unsupported operation: `delete` for collection '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/redis/cache.rs","lineNumber":1073,"sourceCode":"    pipe: &mut Pipeline,\n    collection: &str,\n    key: &str,\n    value: Option<Vec<Bytes>>,\n) -> anyhow::Result<()> {\n    log::debug!(\n        \"delete: collection={}, key={}, has_payload={}\",\n        collection,\n        key,\n        value.is_some()\n    );\n\n    match collection {\n        INDEX => delete_from_index(pipe, key, value),\n        ORDERS | POSITIONS | ACCOUNTS | ACTORS | STRATEGIES => {\n            delete_string(pipe, key);\n            Ok(())\n        }\n        _ => anyhow::bail!(\"Unsupported operation: `delete` for collection '{collection}'\"),\n    }\n}\n\nfn delete_from_index(\n    pipe: &mut Pipeline,\n    key: &str,\n    value: Option<Vec<Bytes>>,\n) -> anyhow::Result<()> {\n    let value = value.ok_or_else(|| anyhow::anyhow!(\"Empty `payload` for `delete` '{key}'\"))?;\n    let index_key = get_index_key(key)?;\n\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","sourceCodeStart":1055,"sourceCodeEnd":1091,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/redis/cache.rs#L1055-L1091","documentation":"delete supports removing entries only from the index (via delete_from_index) and from the ORDERS, POSITIONS, ACCOUNTS, ACTORS, and STRATEGIES string-keyed collections. Any other collection hits the wildcard arm and bails. It prevents delete commands being issued against collection keyspaces this adapter does not own.","triggerScenarios":"Calling delete (e.g. from py_delete) with a collection outside the supported set — INDEX handled specially, so any other collection such as SIGNALS, CUSTOM_DATA, or a typo'd name triggers the error.","commonSituations":"Custom cleanup/flush logic in Python calling cache.delete with an arbitrary collection name; test teardown deleting from collections never written by the Redis adapter; renamed collections after an upgrade.","solutions":["Confirm the collection argument is INDEX, ORDERS, POSITIONS, ACCOUNTS, ACTORS, or STRATEGIES.","Remove unsupported collections via their dedicated APIs (e.g. purge/drop methods) instead of delete.","Extend the match with a new arm if deletion for another collection is genuinely needed.","Guard the call site: only invoke delete for collections the Redis adapter actually writes."],"exampleFix":"// before\ndelete(pipe, \"SIGNALS\", key, value)?; // unsupported\n// after\ndelete(pipe, STRATEGIES, key, value)?;","handlingStrategy":"try-catch","validationCode":"const DELETABLE: [&str; 5] = [ORDERS, POSITIONS, ACCOUNTS, ACTORS, STRATEGIES];\nassert!(collection == INDEX || DELETABLE.contains(&collection));","typeGuard":null,"tryCatchPattern":"// Python\ntry:\n    cache.delete(collection, key, value)\nexcept RuntimeError as e:\n    if \"Unsupported operation: `delete`\" in str(e):\n        log.warning(\"Delete not supported for collection %s; skipping\", collection)\n    else:\n        raise","preventionTips":["Delete only from collections the Redis adapter writes.","Use dedicated purge APIs for other data types.","Centralize delete calls in one helper that validates the collection."],"tags":["redis","cache","unsupported-operation","delete"],"backgroundTag":"unsupported-operation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}