{"record":{"id":"9aa14d79e03a1e48","repo":"slint-ui/slint","slug":"invalid-cargo-toml-cannot-find-workspace-package-section-in","errorCode":null,"errorMessage":"Invalid Cargo.toml -- cannot find workspace package section in workspace file","messagePattern":"Invalid Cargo\\.toml -- cannot find workspace package section in workspace file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/src/license_headers_check.rs","lineNumber":815,"sourceCode":"                .unwrap()\n                .get(\"package\")\n                .unwrap()\n                .get(\"version\")\n                .unwrap()\n                .as_str()\n                .unwrap())\n        }\n    }\n\n    fn package(&self) -> Result<&toml_edit::Table> {\n        if self.is_workspace() {\n            self.doc\n                .as_table()\n                .get(\"workspace\")\n                .and_then(|w| w.as_table())\n                .and_then(|w| w.get(\"package\"))\n                .and_then(|p| p.as_table())\n                .ok_or_else(|| anyhow!(\"Invalid Cargo.toml -- cannot find workspace package section in workspace file\"))\n        } else {\n            self.doc\n                .as_table()\n                .get(\"package\")\n                .and_then(|p| p.as_table())\n                .ok_or_else(|| anyhow!(\"Invalid Cargo.toml -- cannot find package section\"))\n        }\n    }\n\n    fn dependencies(&self, dep_type: &str) -> Vec<(String, CargoDependency)> {\n        let table = if self.is_workspace() {\n            self.doc\n                .as_table()\n                .get(\"workspace\")\n                .and_then(|w| w.as_table())\n                .and_then(|w| w.get(dep_type))\n                .and_then(|d| d.as_table())\n        } else {","sourceCodeStart":797,"sourceCodeEnd":833,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/xtask/src/license_headers_check.rs#L797-L833","documentation":"CargoToml::package() found a [workspace] table but no [workspace.package] table (or it is not a TOML table) in the workspace root manifest, so the workspace-level package settings used for inheritance cannot be read. The manifest is therefore considered invalid for the purposes of the xtask license/version consistency check.","triggerScenarios":"package() is called (from check_and_fix_package_string_field or published) on a workspace root Cargo.toml that lacks a workspace.package section, or whose [workspace] table has no parseable package sub-table.","commonSituations":"A workspace root created without workspace.package metadata (no shared version/license fields); a malformed edit removed [workspace.package]; a manifest with an empty [workspace] table (e.g. a virtual workspace without package inheritance config) is checked.","solutions":["Add a [workspace.package] section with the shared fields (version, license, etc.) to the workspace root Cargo.toml.","Verify the [workspace] table parses as a table and contains package = { ... }; fix any malformed TOML.","If this manifest is a virtual workspace with no intended shared package config, exclude it from this check or handle it before calling package().","Ensure the check runs against the correct manifest path; a member manifest misdetected as a root would trigger this."],"exampleFix":"// before: workspace root missing inheritance metadata\n[workspace]\nmembers = [\"crates/foo\"]\n\n// after\n[workspace]\nmembers = [\"crates/foo\"]\n\n[workspace.package]\nversion = \"1.0.0\"\nlicense = \"GPL-3.0-only OR MIT\"","handlingStrategy":"validation","validationCode":"fn has_workspace_package(doc: &toml_edit::DocumentMut) -> bool {\n    doc.as_table().get(\"workspace\")\n        .and_then(|w| w.as_table())\n        .and_then(|w| w.get(\"package\"))\n        .and_then(|p| p.as_table())\n        .is_some()\n}","typeGuard":"fn workspace_package_table(doc: &toml_edit::DocumentMut) -> Option<&toml_edit::Table> {\n    doc.as_table().get(\"workspace\")?.as_table()?.get(\"package\")?.as_table()\n}","tryCatchPattern":"match cargo_toml.package() {\n    Ok(pkg) => check_fields(pkg),\n    Err(e) if e.to_string().contains(\"workspace package section\") => {\n        anyhow::bail!(\"{}: add a [workspace.package] section with shared version/license\", cargo_toml.path.display())\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Every workspace root must define [workspace.package] with version and license.","Validate workspace manifests in CI before running the consistency check.","Don't delete [workspace.package] when restructuring; members depend on it for inheritance.","Distinguish virtual workspaces (no package inheritance config) and skip or configure them explicitly."],"tags":["cargo","toml","workspace","config","xtask"],"backgroundTag":"missing-required-config-field","analyzedSha":"3a7e700487dc74d404cad0726378053ab763d4e0","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}