{"record":{"id":"697e995a5a93ef33","repo":"nautechsystems/nautilus_trader","slug":"error-parsing-type-e","errorCode":null,"errorMessage":"Error parsing type: {e}","messagePattern":"Error parsing type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/redis/msgbus.rs","lineNumber":843,"sourceCode":"        };\n\n        match key.as_slice() {\n            b\"topic\" => {\n                let redis::Value::BulkString(bytes) = &pair[1] else {\n                    anyhow::bail!(\"Invalid topic format: {stream_msg:?}\");\n                };\n                topic = Some(\n                    String::from_utf8(bytes.clone())\n                        .map_err(|e| anyhow::anyhow!(\"Error parsing topic: {e}\"))?,\n                );\n            }\n            b\"type\" => {\n                let redis::Value::BulkString(bytes) = &pair[1] else {\n                    anyhow::bail!(\"Invalid type format: {stream_msg:?}\");\n                };\n                type_name = Some(\n                    String::from_utf8(bytes.clone())\n                        .map_err(|e| anyhow::anyhow!(\"Error parsing type: {e}\"))?,\n                );\n            }\n            key if key == PAYLOAD_KIND_FIELD.as_bytes() => {\n                let redis::Value::BulkString(bytes) = &pair[1] else {\n                    anyhow::bail!(\"Invalid payload kind format: {stream_msg:?}\");\n                };\n                let value = std::str::from_utf8(bytes)\n                    .map_err(|e| anyhow::anyhow!(\"Error parsing payload kind: {e}\"))?;\n                anyhow::ensure!(\n                    value == PAYLOAD_KIND_TYPED,\n                    \"Unknown payload kind '{value}'\"\n                );\n                typed_payload = true;\n            }\n            b\"encoding\" => {\n                let redis::Value::BulkString(bytes) = &pair[1] else {\n                    anyhow::bail!(\"Invalid encoding format: {stream_msg:?}\");\n                };","sourceCodeStart":825,"sourceCodeEnd":861,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/redis/msgbus.rs#L825-L861","documentation":"decode_bus_message requires the `type` field of a Redis stream entry to be a BulkString holding valid UTF-8 text naming the payload type. If the bytes fail String::from_utf8, this error wraps the FromUtf8Error. The type name is later resolved via BusPayloadType::from_name/from_typed_name.","triggerScenarios":"stream_messages -> decode_bus_message encounters a stream entry whose `type` field bytes are not valid UTF-8.","commonSituations":"Binary garbage written by a buggy producer into the `type` header; custom clients using a different text encoding; corrupted stream data after a Redis persistence/restore issue.","solutions":["Dump the stream entry and confirm the `type` bytes; fix the producer to emit UTF-8 strings.","Check for version skew between publishers and subscribers writing different header encodings.","Remove/re-publish the corrupt entry.","If writing a custom producer, mirror the Nautilus msgbus header encoding (UTF-8 BulkStrings)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if std::str::from_utf8(&type_bytes).is_err() {\n    return Err(\"type header is not UTF-8\".into());\n}","typeGuard":null,"tryCatchPattern":"match decode_bus_message(entry) {\n    Ok(msg) => handle(msg),\n    Err(e) if e.to_string().contains(\"Error parsing type\") => log::warn!(\"corrupt type header, skipping: {e}\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Use the standard publisher API so type names are emitted as UTF-8 strings.","Test round-trip publish/consume in CI to catch header corruption.","Avoid custom binary header encoders."],"tags":["redis","utf8","decoding","streaming"],"backgroundTag":"json-decode-failed","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"}