{"record":{"id":"9f7bc1075af233fe","repo":"clockworklabs/SpacetimeDB","slug":"workspace-section-missing","errorCode":null,"errorMessage":"workspace section missing","messagePattern":"workspace section missing","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/build.rs","lineNumber":454,"sourceCode":"            repo_root.display()\n        )\n    })\n}\n\nfn extract_workspace_metadata(path: &Path) -> io::Result<(String, BTreeMap<String, String>)> {\n    let content = fs::read_to_string(path)?;\n    let parsed: Value = content\n        .parse()\n        .map_err(|err| io::Error::new(io::ErrorKind::InvalidData, err))?;\n\n    let table = parsed\n        .as_table()\n        .ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, \"workspace manifest is not a table\"))?;\n\n    let workspace = table\n        .get(\"workspace\")\n        .and_then(Value::as_table)\n        .ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, \"workspace section missing\"))?;\n\n    let edition = workspace\n        .get(\"package\")\n        .and_then(Value::as_table)\n        .and_then(|pkg| pkg.get(\"edition\"))\n        .and_then(Value::as_str)\n        .unwrap_or(\"2021\")\n        .to_string();\n\n    let mut versions = BTreeMap::new();\n    if let Some(deps) = workspace.get(\"dependencies\").and_then(Value::as_table) {\n        for (name, value) in deps {\n            let version_opt = match value {\n                Value::String(s) => Some(normalize_version(s)),\n                Value::Table(table) => table.get(\"version\").and_then(Value::as_str).map(normalize_version),\n                _ => None,\n            };\n","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/build.rs#L436-L472","documentation":"Same CLI build-script path (crates/cli/build.rs:454): after confirming the root Cargo.toml is a table, extract_workspace_metadata requires a [workspace] section to read workspace.package.edition (defaulting to 2021) and workspace.dependencies versions for the embedded template metadata. A table-rooted manifest without [workspace] produces this InvalidData error, and the .expect() at build.rs:104 panics the build.","triggerScenarios":"Building the `spacetime` CLI when the root Cargo.toml is valid table-rooted TOML but contains no [workspace] section - e.g. the root was converted to a plain package manifest, or [workspace] was dropped in a merge.","commonSituations":"Forks that restructure the repo (moving the workspace elsewhere) without leaving a root workspace manifest; automated dependency bots deleting sections they do not understand; a crate manifest copy-pasted over the root.","solutions":["Restore a [workspace] section in the root Cargo.toml with the crate members (e.g. [workspace] with members = [\"crates/*\"]).","Recover the section from git history: `git show HEAD:Cargo.toml`.","If the workspace root genuinely moved, restore the expected repo layout so crates/cli/build.rs finds the original root manifest."],"exampleFix":"# before (root Cargo.toml)\n[package]\nname = \"root\"\nversion = \"0.1.0\"\n\n# after\n[workspace]\nmembers = [\"crates/*\"]","handlingStrategy":"validation","validationCode":"let parsed: toml::Value = std::fs::read_to_string(\"Cargo.toml\")?.parse()?;\nanyhow::ensure!(\n    parsed.get(\"workspace\").map(|w| w.is_table()).unwrap_or(false),\n    \"root Cargo.toml is missing its [workspace] section\"\n);","typeGuard":null,"tryCatchPattern":"match extract_workspace_metadata(&workspace_cargo) {\n    Ok(meta) => meta,\n    Err(e) if e.kind() == io::ErrorKind::InvalidData && e.to_string().contains(\"workspace section\") => {\n        // restore [workspace] from git history, then rebuild\n        return Err(anyhow!(\"{e}\"));\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Run `cargo metadata --no-deps` in CI - it fails fast when [workspace] is missing.","Keep dependency bots and merge tooling from deleting manifest sections they do not recognize.","After restructuring a fork, confirm crates/cli/build.rs still finds a root workspace manifest at the repo root."],"tags":["rust","cargo","toml","workspace","build-script"],"backgroundTag":"missing-cargo-workspace-section","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}