{"record":{"id":"00fc2343392f7e24","repo":"nautechsystems/nautilus_trader","slug":"index-unknown-index-key-on-read","errorCode":null,"errorMessage":"Index unknown '{index_key}' on read","messagePattern":"Index unknown '(.+?)' on read","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/redis/queries.rs","lineNumber":986,"sourceCode":"            .ok_or_else(|| {\n                anyhow::anyhow!(\"Invalid `key`, missing a '{REDIS_DELIMITER}' delimiter, was {key}\")\n            })\n    }\n\n    async fn read_index(conn: &mut ConnectionManager, key: &str) -> anyhow::Result<Vec<Bytes>> {\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 => Self::read_set(conn, key).await,\n            INDEX_ORDER_POSITION | INDEX_ORDER_CLIENT => Self::read_hset(conn, key).await,\n            _ => anyhow::bail!(\"Index unknown '{index_key}' on read\"),\n        }\n    }\n\n    async fn read_string(conn: &mut ConnectionManager, key: &str) -> anyhow::Result<Vec<Bytes>> {\n        let result: Vec<u8> = conn.get(key).await?;\n\n        if result.is_empty() {\n            Ok(vec![])\n        } else {\n            Ok(vec![Bytes::from(result)])\n        }\n    }\n\n    async fn read_set(conn: &mut ConnectionManager, key: &str) -> anyhow::Result<Vec<Bytes>> {\n        let result: Vec<Bytes> = conn.smembers(key).await?;\n        Ok(result)\n    }\n","sourceCodeStart":968,"sourceCodeEnd":1004,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/redis/queries.rs#L968-L1004","documentation":"read_index dispatches on the index key and only recognizes the defined index constants (order, order-emulated, order-inflight, position, positions-open/closed, order-position, order-client mappings). An index key outside that set cannot be mapped to a set or hset read, so it bails. This guards against reading malformed or foreign index keys from Redis.","triggerScenarios":"Calling read_index (directly or via INDEX collection reads) with an index key string that is not one of the INDEX_* constants — a typo, a hand-built key, or an index type introduced in a different version.","commonSituations":"Custom tooling that scans Redis and feeds every key back through the cache reader; schema drift between nautilus versions where new index kinds exist but the reader predates them; concatenating index key prefixes incorrectly.","solutions":["Verify the index key matches one of the INDEX_* key formats produced by the writer (crates/infrastructure/src/redis/queries.rs) and correct the key construction","Use the library's index-key builder functions instead of hand-assembling keys","Add the new index kind to the read_index match if it was introduced intentionally"],"exampleFix":"// before\nlet key = format!(\"{trader}:index:orders-open\"); // wrong suffix\n// after\nlet key = index_key(INDEX_POSITIONS_OPEN, &trader); // use library key builder","handlingStrategy":"validation","validationCode":"const KNOWN_INDEXES: &[&str] = &[INDEX_ORDERS, INDEX_ORDERS_EMULATED, INDEX_ORDERS_INFLIGHT, INDEX_POSITIONS, INDEX_POSITIONS_OPEN, INDEX_POSITIONS_CLOSED, INDEX_ORDER_POSITION, INDEX_ORDER_CLIENT];\nif !KNOWN_INDEXES.iter().any(|k| index_key.contains(k)) { return Err(anyhow!(\"unknown index key {index_key}\")); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build index keys with the library's key-format functions, never by string concatenation","Keep reader and writer versions in sync","Sanitize/skip foreign keys when scanning Redis"],"tags":["redis","cache","index","unsupported-operation"],"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"}