{"record":{"id":"10cef0a60d4bf093","repo":"databendlabs/databend","slug":"message","errorCode":null,"errorMessage":"{message}","messagePattern":"\\{message\\}","errorType":"exception","errorClass":"InvalidData","httpStatus":null,"severity":"error","filePath":"src/meta/api/src/error/constructors.rs","lineNumber":33,"sourceCode":"use std::fmt::Display;\nuse std::io;\n\nuse databend_common_meta_app::app_error::AppError;\nuse databend_common_meta_app::app_error::DatabaseAlreadyExists;\nuse databend_common_meta_app::app_error::TableAlreadyExists;\nuse databend_common_meta_app::app_error::UnknownDatabase;\nuse databend_common_meta_app::app_error::UnknownDatabaseId;\nuse databend_common_meta_app::app_error::UnknownTable;\nuse databend_common_meta_app::schema::TableNameIdent;\nuse databend_common_meta_app::schema::database_name_ident::DatabaseNameIdent;\nuse databend_meta_client::types::InvalidReply;\n\nuse super::app_error::KVAppError;\n\npub(crate) fn invalid_reply<M>(message: M) -> InvalidReply\nwhere M: Display {\n    let message = message.to_string();\n    let source = io::Error::new(io::ErrorKind::InvalidData, message.clone());\n    InvalidReply::new(message, &source)\n}\n\npub fn unknown_database_error(db_name_ident: &DatabaseNameIdent, msg: impl Display) -> AppError {\n    let e = UnknownDatabase::new(\n        db_name_ident.database_name(),\n        format!(\"{}: {}\", msg, db_name_ident.display()),\n    );\n    AppError::UnknownDatabase(e)\n}\n\npub fn db_has_to_exist(\n    seq: u64,\n    db_name_ident: &DatabaseNameIdent,\n    msg: impl Display,\n) -> Result<(), KVAppError> {\n    if seq == 0 {\n        Err(KVAppError::AppError(unknown_database_error(","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/meta/api/src/error/constructors.rs#L15-L51","documentation":"The meta-service's invalid_reply constructor builds an InvalidReply error carrying an arbitrary message. It is raised whenever a meta API handler receives a reply whose shape/content is not what the caller expects (e.g. a reply variant that does not match the request, or missing fields). The message is embedded in both the error text and an io::Error of kind InvalidData used as its source.","triggerScenarios":"Any meta API path that validates replies — list_lock_revisions_v2, create_lock_revision_v2, CreateLockRevReply construction, list_locks_v2, get_mv_definition_snapshot, list_segment_claims — receiving a reply message of the wrong type or with missing/invalid content, producing a call like invalid_reply(format!(...)).","commonSituations":"Mixed-version meta clusters where an older node returns a reply format a newer caller cannot interpret; a handler returning the wrong reply variant for a request; Raft/KV state desynchronized so an expected key or record is absent from the reply.","solutions":["Read the error message to see which reply field or variant was unexpected.","Check for mixed meta-node versions in the cluster and upgrade nodes to the same release.","Inspect the meta handler for the failing API to ensure it returns the reply variant matching the request (e.g. correct CreateLockRevReply fields).","Retry the operation if it followed a leadership change / transient Raft state; verify cluster health with the meta admin API."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// no pre-call check possible; validate reply shape after the call instead\nif !matches!(reply, MetaReply::ListLockRevisions(_)) {\n    return Err(invalid_reply(format!(\"expect list_lock_revisions reply, got {reply:?}\")));\n}","typeGuard":null,"tryCatchPattern":"match meta_api.list_locks_v2(&ident).await {\n    Err(KVAppError::InvalidReply(e)) if is_transient(&e) => {\n        // retry once after a leadership/state change\n        tokio::time::sleep(RETRY_DELAY).await;\n        meta_api.list_locks_v2(&ident).await\n    }\n    other => other,\n}","preventionTips":["Keep all meta nodes on the same Databend version.","After meta cluster upgrades, smoke-test lock APIs before production traffic.","Log the full reply on mismatch so handlers returning wrong variants are caught in CI/tests."],"tags":["meta-service","rpc","protobuf","internal"],"backgroundTag":"unexpected-api-response-shape","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"}