{"record":{"id":"4e57946c806e2a83","repo":"tinyhumansai/openhuman","slug":"expected-one-top-level-folder-under-found-n-4e5794","errorCode":null,"errorMessage":"expected one top-level folder under {}, found {n}","messagePattern":"expected one top-level folder under (.+?), found (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/openhuman/runtime/python/extractor.rs","lineNumber":55,"sourceCode":"    let mut entries = fs::read_dir(extract_root)\n        .with_context(|| format!(\"listing {}\", extract_root.display()))?\n        .collect::<Result<Vec<_>, _>>()\n        .with_context(|| format!(\"reading entries of {}\", extract_root.display()))?;\n    entries.sort_by_key(|e| e.file_name());\n\n    let mut dirs = entries\n        .into_iter()\n        .filter(|e| e.file_type().map(|t| t.is_dir()).unwrap_or(false))\n        .map(|e| e.path())\n        .collect::<Vec<_>>();\n\n    match dirs.len() {\n        1 => Ok(dirs.pop().expect(\"single dir\")),\n        0 => Err(anyhow!(\n            \"expected one top-level folder under {}, found none\",\n            extract_root.display()\n        )),\n        n => Err(anyhow!(\n            \"expected one top-level folder under {}, found {n}\",\n            extract_root.display()\n        )),\n    }\n}\n\npub async fn atomic_install(staged: &Path, final_dest: &Path) -> Result<PathBuf> {\n    let staged = staged.to_path_buf();\n    let final_dest = final_dest.to_path_buf();\n\n    tokio::task::spawn_blocking(move || -> Result<PathBuf> {\n        if let Some(parent) = final_dest.parent() {\n            fs::create_dir_all(parent)\n                .with_context(|| format!(\"creating parent {}\", parent.display()))?;\n        }\n\n        let backup = if final_dest.exists() {\n            let candidate = final_dest.with_extension(format!(\"old-{}\", std::process::id()));","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/runtime/python/extractor.rs#L37-L73","documentation":"The counterpart guard in find_single_top_level(): after listing and sorting the extract root, more than one top-level directory was found (n != 1), so the extractor cannot decide which folder is the Python installation to move into place. Fires on malformed or unexpected archives (nested layouts, junk directories bundled into the tarball) or a stale, non-empty extract root left by a previous failed run. Generic guard; faulty input is the set of extracted top-level entries.","triggerScenarios":"Thrown at src/openhuman/runtime/python/extractor.rs:55 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Clear the extract root of leftover content from prior installs and retry the download+extract.","Prefer/validate the single expected cpython-* directory name if upstream ever ships extra top-level entries.","Verify the downloaded asset is the install_only variant, whose layout is exactly one top-level folder."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}