{"record":{"id":"c57d4c99ebc6ba99","repo":"risingwavelabs/risingwave","slug":"cannot-decode-user-key-into-raw-bytes","errorCode":null,"errorMessage":"cannot decode user key {} into raw bytes","messagePattern":"cannot decode user key (.+?) into raw bytes","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ctl/src/cmd_impl/hummock/validate_version.rs","lineNumber":73,"sourceCode":"    archive_object_store: ObjectStoreRef,\n) -> anyhow::Result<HummockVersionArchive> {\n    use prost::Message;\n    let archive_dir = version_archive_dir(data_dir);\n    let archive_path = format!(\"{archive_dir}/{archive_id}\");\n    let archive_bytes = archive_object_store.read(&archive_path, ..).await?;\n    let archive: HummockVersionArchive = HummockVersionArchive::decode(archive_bytes)?;\n    Ok(archive)\n}\n\npub async fn print_user_key_in_archive(\n    context: &CtlContext,\n    archive_ids: impl IntoIterator<Item = HummockVersionId>,\n    data_dir: String,\n    user_key: String,\n    use_new_object_prefix_strategy: bool,\n) -> anyhow::Result<()> {\n    let user_key_bytes = hex::decode(user_key.clone()).unwrap_or_else(|_| {\n        panic!(\"cannot decode user key {} into raw bytes\", user_key);\n    });\n    let user_key = UserKey::decode(&user_key_bytes);\n    println!(\"user key: {user_key:?}\");\n\n    let hummock_opts =\n        HummockServiceOpts::from_env(Some(data_dir.clone()), use_new_object_prefix_strategy)?;\n    let hummock = context.hummock_store(hummock_opts).await?;\n    let sstable_store = hummock.sstable_store();\n    let archive_object_store = sstable_store.store();\n    for archive_id in archive_ids.into_iter().sorted() {\n        println!(\"search archive {archive_id}\");\n        let archive = get_archive(archive_id, &data_dir, archive_object_store.clone()).await?;\n        let mut base_version =\n            HummockVersion::from_persisted_protobuf(archive.version.as_ref().unwrap());\n        print_user_key_in_version(sstable_store.clone(), &base_version, &user_key).await?;\n        for delta in &archive.version_deltas {\n            base_version.apply_version_delta(&HummockVersionDelta::from_persisted_protobuf(delta));\n            print_user_key_in_version(sstable_store.clone(), &base_version, &user_key).await?;","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/ctl/src/cmd_impl/hummock/validate_version.rs#L55-L91","documentation":"print_user_key_in_archive expects the user_key argument to be a hex-encoded byte string that decodes into a Hummock UserKey. If hex decoding fails the command panics, since there is no meaningful way to proceed without the key bytes.","triggerScenarios":"Passing a user_key argument containing non-hex characters or an odd number of characters, e.g. a raw string instead of its hex encoding.","commonSituations":"Copying a user key from logs and forgetting to hex-encode (or copying only part of it); passing a human-readable key; shell mangling of the argument.","solutions":["Hex-encode the user key before passing it (e.g. `echo -n <bytes> | xxd -p` or using the original hex string from logs)","Check for accidental whitespace or characters outside [0-9a-fA-F] and even length","Re-extract the key from the manifest/SST debug output that provides it in hex"],"exampleFix":"// before\nrw hummock print-user-key ... --user-key 'row_id=1'\n// after\nrw hummock print-user-key ... --user-key 'fa1e000001'","handlingStrategy":"validation","validationCode":"if user_key.len() % 2 != 0 || !user_key.bytes().all(|b| b.is_ascii_hexdigit()) {\n    panic!(\"user_key must be a hex string\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always copy user keys in hex from the tool/log output","Encode raw keys with `xxd -p` or equivalent before passing","Check for even length and hex-only characters"],"tags":["hex","decoding","cli","panic"],"backgroundTag":"invalid-argument-format","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}