databendlabs/databend · warning
expect InvalidReply
Error message
expect InvalidReply
What it means
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.
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
Example fix
// before
_ => { /* returned Ok(reply) or wrong error */ }
// after
impl From<RaftReply> for TxnReply {
fn from(r: RaftReply) -> Self {
... map decode failure of r.data to ErrorCode::InvalidReply("can not decode RaftReply.data") ...
}
} Defensive patterns
Strategy: validation
Validate before calling
// test-only; validate reply conversion contract in tests assert!(matches!(TxnReply::from(bad_reply).error, ErrorCode::InvalidReply(_)));
Prevention
- 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
When it happens
Trigger: 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.
Common situations: Refactoring src/meta/api/src/txn/reply.rs error handling; introducing a new error representation in RaftReply; breaking serde round-trip of RaftReply.data.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Unsupported format for
- Unsupported source type. Expected path, pandas.DataFrame…
- Access denied: is outside allowed directories
- rename_database: src (db) should exist
- internal error: expect TxnGetResponseGet of get database…
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/1c227f4b3a9f6aa9.
Report an issue: GitHub.
Appendix: source
Thrown at src/meta/api/src/txn/reply.rs:72
#[test]
fn test_valid_reply() -> anyhow::Result<()> {
// Unable to decode `.data`
let msg = RaftReply {
data: "foo".to_string(),
error: "".to_string(),
};
let res: Result<Foo, MetaAPIError> = reply_to_api_result(msg);
match res {
Err(MetaAPIError::NetworkError(MetaNetworkError::InvalidReply(inv_reply))) => {
assert!(
inv_reply
.to_string()
.starts_with("InvalidReply: can not decode RaftReply.data")
);
}
_ => {
unreachable!("expect InvalidReply")
}
}
// Unable to decode `.error`
let msg = RaftReply {
data: "".to_string(),
error: "foo".to_string(),
};
let res: Result<Foo, MetaAPIError> = reply_to_api_result(msg);
match res {
Err(MetaAPIError::NetworkError(MetaNetworkError::InvalidReply(inv_reply))) => {
assert!(
inv_reply
.to_string()
.starts_with("InvalidReply: can not decode RaftReply.error")
);
}View on GitHub (pinned to 288d84d76e)