{"record":{"id":"d30698991cd60d5a","repo":"nautechsystems/nautilus_trader","slug":"invalid-key-missing-a-redis-delimiter-delim","errorCode":null,"errorMessage":"Invalid `key`, missing a '{REDIS_DELIMITER}' delimiter, was {key}","messagePattern":"Invalid `key`, missing a '(.+?)' delimiter, was (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/redis/cache.rs","lineNumber":1218,"sourceCode":"    if config.use_trader_prefix {\n        key.push_str(\"trader-\");\n    }\n\n    key.push_str(trader_id.as_str());\n\n    if config.use_instance_id {\n        key.push(REDIS_DELIMITER);\n        write!(key, \"{instance_id}\").expect(\"writing to String cannot fail\");\n    }\n\n    key\n}\n\nfn get_collection_key(key: &str) -> anyhow::Result<&str> {\n    key.split_once(REDIS_DELIMITER)\n        .map(|(collection, _)| collection)\n        .ok_or_else(|| {\n            anyhow::anyhow!(\"Invalid `key`, missing a '{REDIS_DELIMITER}' delimiter, was {key}\")\n        })\n}\n\n#[derive(Debug)]\npub struct RedisCacheDatabaseAdapter {\n    pub database: RedisCacheDatabase,\n}\n\nimpl RedisCacheDatabaseAdapter {\n    fn encoding(&self) -> SerializationEncoding {\n        self.database.get_encoding()\n    }\n\n    fn send_command(\n        &self,\n        op_type: DatabaseOperation,\n        key: String,\n        payload: Option<Vec<Bytes>>,","sourceCodeStart":1200,"sourceCodeEnd":1236,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/redis/cache.rs#L1200-L1236","documentation":"When draining the write buffer, each Redis key must be of the form '<collection><delimiter><suffix>' so the cache can determine which collection (orders, positions, etc.) it belongs to. get_collection_key splits on the REDIS_DELIMITER (colon) and raises this error when a key contains no delimiter. It indicates a malformed or foreign key entered the cache buffer.","triggerScenarios":"drain_buffer processes a buffered key that lacks the REDIS_DELIMITER separator — e.g. a key written without the expected '<COLLECTION>:...' prefix format.","commonSituations":"Custom code or an older/other component writing cache keys in a different format, a corrupted/migrated Redis dataset being drained, or manual key construction that skipped the delimiter convention.","solutions":["Log/inspect the offending key and rewrite it using the standard '<COLLECTION>{REDIS_DELIMITER}...' format.","Check any custom writers to the cache buffer and ensure keys use the same delimiter convention as the built-in adapters.","If keys come from an older schema or migration, transform them to the current format before draining.","Upgrade nautilus_trader if the delimiter constant changed between versions and old keys no longer match."],"exampleFix":"// before\nbuffer.push(\"mykey123\", payload);\n// after\nbuffer.push(format!(\"{ORDERS}{REDIS_DELIMITER}mykey123\"), payload);","handlingStrategy":"validation","validationCode":"fn key_is_valid(key: &str, delim: char) -> bool { key.contains(delim) && !key.starts_with(delim) }","typeGuard":"fn is_collection_key(key: &str) -> bool { key.split_once(':').is_some() }","tryCatchPattern":null,"preventionTips":["Always build cache keys with the '<COLLECTION>{REDIS_DELIMITER}...' convention.","Validate keys before pushing them into the write buffer.","Migrate legacy keys to the current format before draining."],"tags":["rust","redis","key-format","drain"],"backgroundTag":"invalid-argument-format","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"}