{"record":{"id":"1c227f4b3a9f6aa9","repo":"databendlabs/databend","slug":"expect-invalidreply","errorCode":null,"errorMessage":"expect InvalidReply","messagePattern":"expect InvalidReply","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/meta/api/src/txn/reply.rs","lineNumber":72,"sourceCode":"    #[test]\n    fn test_valid_reply() -> anyhow::Result<()> {\n        // Unable to decode `.data`\n\n        let msg = RaftReply {\n            data: \"foo\".to_string(),\n            error: \"\".to_string(),\n        };\n        let res: Result<Foo, MetaAPIError> = reply_to_api_result(msg);\n        match res {\n            Err(MetaAPIError::NetworkError(MetaNetworkError::InvalidReply(inv_reply))) => {\n                assert!(\n                    inv_reply\n                        .to_string()\n                        .starts_with(\"InvalidReply: can not decode RaftReply.data\")\n                );\n            }\n            _ => {\n                unreachable!(\"expect InvalidReply\")\n            }\n        }\n\n        // Unable to decode `.error`\n\n        let msg = RaftReply {\n            data: \"\".to_string(),\n            error: \"foo\".to_string(),\n        };\n        let res: Result<Foo, MetaAPIError> = reply_to_api_result(msg);\n        match res {\n            Err(MetaAPIError::NetworkError(MetaNetworkError::InvalidReply(inv_reply))) => {\n                assert!(\n                    inv_reply\n                        .to_string()\n                        .starts_with(\"InvalidReply: can not decode RaftReply.error\")\n                );\n            }","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/meta/api/src/txn/reply.rs#L54-L90","documentation":"This is a test-only assertion inside test_valid_reply in the txn reply module. The test constructs a RaftReply whose data cannot be decoded and expects the reply converter to produce an InvalidReply error variant; if it returns any other variant the unreachable!() panics with 'expect InvalidReply'. End users only encounter this if running or modifying the test suite — it is a guard that the error-decoding contract holds.","triggerScenarios":"Modifying the reply conversion code (RaftReply -> TxnReply) so that undecodable .data no longer maps to ErrorCode::InvalidReply, then running the meta-api tests; or adding a new RaftFields variant not covered by the conversion match.","commonSituations":"Refactoring src/meta/api/src/txn/reply.rs error handling; introducing a new error representation in RaftReply; breaking serde round-trip of RaftReply.data.","solutions":["Fix the reply conversion so undecodable RaftReply.data maps to ErrorCode::InvalidReply whose message starts with 'InvalidReply: can not decode RaftReply.data'","Ensure new RaftFields/error variants are added to the From<RaftReply> conversion match arms","Run `cargo test -p databend-meta -- test_valid_reply` to confirm the conversion contract"],"exampleFix":"// before\n_ => { /* returned Ok(reply) or wrong error */ }\n// after\nimpl From<RaftReply> for TxnReply {\n    fn from(r: RaftReply) -> Self {\n        ... map decode failure of r.data to ErrorCode::InvalidReply(\"can not decode RaftReply.data\") ...\n    }\n}","handlingStrategy":"validation","validationCode":"// test-only; validate reply conversion contract in tests\nassert!(matches!(TxnReply::from(bad_reply).error, ErrorCode::InvalidReply(_)));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Extend From<RaftReply> conversion for every new RaftFields variant","Run test_valid_reply when touching txn/reply.rs","Keep the 'InvalidReply: can not decode RaftReply.data' message prefix stable"],"tags":["rust","meta-service","tests","error-handling"],"backgroundTag":"internal-invariant-violation","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}