{"record":{"id":"95a59acfd687e44a","repo":"databendlabs/databend","slug":"no-data-found","errorCode":null,"errorMessage":"no data found","messagePattern":"no data found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/meta/control/src/reading.rs","lineNumber":33,"sourceCode":"//! Supporting utilities for reading exported data.\n\nuse std::io::BufRead;\nuse std::io::Lines;\nuse std::iter::Peekable;\n\nuse databend_meta::raft_config::data_version::DATA_VERSION;\nuse databend_meta::raft_config::data_version::DataVersion;\nuse databend_meta::store_compat::ondisk::TREE_HEADER;\nuse databend_meta::store_compat::sled_compat::key_spaces::RaftStoreEntry;\n\n/// Import from lines of exported data and Return the max log id that is found.\npub fn validate_version<B: BufRead + 'static>(\n    lines: &mut Peekable<Lines<B>>,\n) -> anyhow::Result<DataVersion> {\n    #[allow(clippy::useless_conversion)]\n    let first = lines\n        .peek()\n        .ok_or_else(|| anyhow::anyhow!(\"no data found\"))?;\n\n    let first_line = match first {\n        Ok(l) => l,\n        Err(e) => {\n            return Err(anyhow::anyhow!(\"{}\", e));\n        }\n    };\n\n    // First line is the data header that containing version.\n    let version = read_version(first_line)?;\n\n    if !DATA_VERSION.is_compatible(version) {\n        return Err(anyhow::anyhow!(\n            \"invalid data version: {:?}, This program version is {:?}; The latest compatible program version is: {:?}\",\n            version,\n            DATA_VERSION,\n            version.max_compatible_working_version(),\n        ));","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/meta/control/src/reading.rs#L15-L51","documentation":"validate_version reads the first line of a streamed data dump (meta backup/upgrade payload) via lines.peek(); if the iterator is empty — no data at all — it returns \"no data found\". It guards against being handed an empty file or stream where a version header is mandatory.","triggerScenarios":"Calling validate_version with an empty reader: zero lines remain in the Peekable<Lines<B>>, so peek() returns None.","commonSituations":"Restoring a meta data backup from a truncated or empty file; piping an empty stdin to the meta upgrade tool; a failed export produced a 0-byte dump.","solutions":["Check the dump file exists and is non-empty (ls -l / wc -c) before running the restore/upgrade","Re-create the backup/export; the source produced no data","Verify you are pointing the tool at the correct input file, not a placeholder path","If streaming, confirm the upstream writer actually flushed and closed successfully"],"exampleFix":"// before\nlet f = File::open(&path)?;\nvalidate_version(BufReader::new(f).lines().peekable())?;\n// after\nlet meta = std::fs::metadata(&path)?;\nanyhow::ensure!(meta.len() > 0, \"dump file {} is empty\", path.display());\nlet f = File::open(&path)?;","handlingStrategy":"validation","validationCode":"let md = std::fs::metadata(&dump_path)?;\nanyhow::ensure!(md.len() > 0, \"dump {} is empty\", dump_path.display());","typeGuard":"fn has_first_line<R: BufRead>(r: &mut Peekable<Lines<R>>) -> bool { r.peek().is_some() }","tryCatchPattern":"match validate_version(&mut lines) {\n    Err(e) if e.to_string() == \"no data found\" => bail!(\"dump file is empty; regenerate the backup\"),\n    other => other?,\n}","preventionTips":["Check file size after every backup/export","Verify the pipeline step that produced the dump exited 0","Point tooling at real files, never placeholder paths"],"tags":["meta-service","data-version","empty-input"],"backgroundTag":"empty-result-set","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"}