diff --git a/Cargo.lock b/Cargo.lock index 2af0887a305e..6e8fb5735e30 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4096,6 +4096,7 @@ dependencies = [ "databend-common-protos", "enumflags2", "fastrace", + "log", "maplit", "num", "pretty_assertions", diff --git a/src/meta/proto-conv/Cargo.toml b/src/meta/proto-conv/Cargo.toml index 0aa5e663d00d..488ba3211dae 100644 --- a/src/meta/proto-conv/Cargo.toml +++ b/src/meta/proto-conv/Cargo.toml @@ -16,6 +16,7 @@ databend-common-meta-types = { workspace = true } databend-common-protos = { workspace = true } enumflags2 = { workspace = true } fastrace = { workspace = true } +log = { workspace = true } num = { workspace = true } prost = { workspace = true } thiserror = { workspace = true } diff --git a/src/meta/proto-conv/src/user_from_to_protobuf_impl.rs b/src/meta/proto-conv/src/user_from_to_protobuf_impl.rs index 175b0122b9f2..5cb2cc8e6ba6 100644 --- a/src/meta/proto-conv/src/user_from_to_protobuf_impl.rs +++ b/src/meta/proto-conv/src/user_from_to_protobuf_impl.rs @@ -160,7 +160,7 @@ impl FromToProto for mt::principal::GrantObject { reader_check_msg(p.ver, p.min_reader_ver)?; let Some(object) = p.object else { - return Err(Incompatible::new("GrantObject cannot be None".to_string())); + return Err(Incompatible::new(format!("Incompatible GrantObject type: Data contains an unrecognized variant for {} version", p.ver))); }; match object { @@ -295,7 +295,13 @@ impl FromToProto for mt::principal::UserGrantSet { let mut entries = Vec::new(); for entry in p.entries.iter() { - entries.push(mt::principal::GrantEntry::from_pb(entry.clone())?); + // If we add new GrantObject in new version + // Rollback to old version, GrantEntry.object will be None + // GrantEntry::from_pb will return err so user can not login in old version. + match mt::principal::GrantEntry::from_pb(entry.clone()) { + Ok(entry) => entries.push(entry), + Err(e) => log::error!("GrantEntry::from_pb with error : {e}"), + } } let mut roles = HashSet::new(); for role in p.roles.iter() {