{"record":{"id":"9a21acac5b38583c","repo":"nautechsystems/nautilus_trader","slug":"invalid-index-key-format-key","errorCode":null,"errorMessage":"Invalid index key format: {key}","messagePattern":"Invalid index key format: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/redis/mod.rs","lineNumber":51,"sourceCode":"const REDIS_INDEX_PATTERN: &str = \":index:\";\nconst REDIS_XTRIM: &str = \"XTRIM\";\nconst REDIS_MINID: &str = \"MINID\";\nconst REDIS_FLUSHDB: &str = \"FLUSHDB\";\n\n/// Extracts the index key from a full Redis key.\n///\n/// Handles keys with `instance_id` prefix by finding the `:index:` pattern.\n/// For example, `trader-id:uuid:index:order_position` -> `index:order_position`.\npub(crate) fn get_index_key(key: &str) -> anyhow::Result<&str> {\n    if let Some(pos) = key.find(REDIS_INDEX_PATTERN) {\n        return Ok(&key[pos + 1..]);\n    }\n\n    if key.starts_with(\"index:\") {\n        return Ok(key);\n    }\n\n    anyhow::bail!(\"Invalid index key format: {key}\")\n}\n\nasync fn await_handle(handle: Option<tokio::task::JoinHandle<()>>, task_name: &str) {\n    if let Some(handle) = handle {\n        log_task_awaiting(task_name);\n\n        let timeout = Duration::from_secs(2);\n        match tokio::time::timeout(timeout, handle).await {\n            Ok(result) => {\n                if let Err(e) = result {\n                    log::error!(\"Error awaiting task '{task_name}': {e:?}\");\n                }\n            }\n            Err(_) => {\n                log::warn!(\"Timeout {timeout:?} awaiting task '{task_name}'\");\n            }\n        }\n    }","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/redis/mod.rs#L33-L69","documentation":"Key-format guard in get_index_key: Redis index keys must either contain the ':index:' delimiter (instance-prefixed form) or start with 'index:'; anything else is not a recognizable index key and is rejected.","triggerScenarios":"Thrown at crates/infrastructure/src/redis/mod.rs:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass keys produced by the index write path","Prefix the key with the instance id and ':index:' or use the bare 'index:...' form"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}