Skip to content

refactor(query): Gracefully handle unknown GrantEntry objects in UserGrantSet::from_pb #18400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/meta/proto-conv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
10 changes: 8 additions & 2 deletions src/meta/proto-conv/src/user_from_to_protobuf_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand Down
Loading