{"record":{"id":"ddabe8f5e3858013","repo":"nautechsystems/nautilus_trader","slug":"index-unknown-index-key-on-insert","errorCode":null,"errorMessage":"Index unknown '{index_key}' on insert","messagePattern":"Index unknown '(.+?)' on insert","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/redis/cache.rs","lineNumber":996,"sourceCode":"            Ok(())\n        }\n        INDEX_ORDER_CLIENT => {\n            if !value.len().is_multiple_of(2) {\n                anyhow::bail!(\n                    \"Invalid hash index payload for '{index_key}': expected field-value pairs\"\n                );\n            }\n\n            let entries = value\n                .as_chunks::<2>()\n                .0\n                .iter()\n                .map(|entry| (entry[0].as_ref(), entry[1].as_ref()))\n                .collect::<Vec<(&[u8], &[u8])>>();\n            pipe.hset_multiple(key, &entries);\n            Ok(())\n        }\n        _ => anyhow::bail!(\"Index unknown '{index_key}' on insert\"),\n    }\n}\n\nfn insert_string(pipe: &mut Pipeline, key: &str, value: &[u8]) {\n    pipe.set(key, value);\n}\n\nfn insert_set(pipe: &mut Pipeline, key: &str, value: &[u8]) {\n    pipe.sadd(key, value);\n}\n\nfn insert_hset(pipe: &mut Pipeline, key: &str, name: &[u8], value: &[u8]) {\n    pipe.hset(key, name, value);\n}\n\nfn insert_list(pipe: &mut Pipeline, key: &str, value: &[u8]) {\n    pipe.rpush(key, value);\n}","sourceCodeStart":978,"sourceCodeEnd":1014,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/redis/cache.rs#L978-L1014","documentation":"insert_index matches the index key against the known index constants (INDEX_ORDER_POSITION, INDEX_ORDER_CLIENT, etc.). If the index_key does not match any supported index, the match falls to the wildcard arm and bails with this error. It is an exhaustiveness guard over the set of index types the Redis cache knows how to write.","triggerScenarios":"Calling insert_index (via insert) with an index_key string that is not one of the defined INDEX_* constants — e.g. a typo'd index name, a custom index introduced upstream but not yet supported by this adapter, or an index constant renamed.","commonSituations":"Version mismatch where a newer NautilusTrader core emits an index the installed redis cache crate version does not know; copy-paste typo in index key; a fork adding custom indexes without extending insert_index.","solutions":["Print the index_key value at the call site and compare it against the INDEX_* constants in cache.rs.","Correct the index key typo to a supported constant (INDEX_ORDER_POSITION or INDEX_ORDER_CLIENT).","If a new index type is legitimately needed, add a match arm in insert_index implementing the write (e.g. via insert_hset or hset_multiple).","Align crate versions so core and the redis adapter agree on the index constants."],"exampleFix":"// before\ninsert(pipe, \"order:my_custom_idx\", key, value)?; // unknown index\n// after\ninsert(pipe, INDEX_ORDER_CLIENT, key, value)?; // supported index","handlingStrategy":"validation","validationCode":"// Only pass the constants themselves, never constructed strings\nconst SUPPORTED: [&str; 2] = [INDEX_ORDER_POSITION, INDEX_ORDER_CLIENT];\nassert!(SUPPORTED.contains(&index_key), \"unsupported index: {index_key}\");","typeGuard":null,"tryCatchPattern":"// Python\ntry:\n    cache.insert(index_key, key, value)\nexcept RuntimeError as e:\n    if \"Index unknown\" in str(e):\n        log.warning(\"Skipping unknown index %s\", index_key)\n    else:\n        raise","preventionTips":["Reference the INDEX_* constants directly instead of hand-writing index key strings.","Keep core and redis-adapter crate versions in sync.","Add a match-arm test covering every index constant used in your deployment."],"tags":["redis","cache","unknown-value","match-arm"],"backgroundTag":"unsupported-enum-value","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"}