{"record":{"id":"3224748d63ae257a","repo":"slint-ui/slint","slug":"invalid-cargo-toml-cannot-find-package-section","errorCode":null,"errorMessage":"Invalid Cargo.toml -- cannot find package section","messagePattern":"Invalid Cargo\\.toml -- cannot find package section","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/src/license_headers_check.rs","lineNumber":821,"sourceCode":"                .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 {\n            self.doc.as_table().get(dep_type).and_then(|d| d.as_table())\n        };\n        match table {\n            Some(dep_table) => dep_table\n                .iter()\n                .filter_map(|(name, entry)| {","sourceCodeStart":803,"sourceCodeEnd":839,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/xtask/src/license_headers_check.rs#L803-L839","documentation":"CargoToml::package() was called on a non-workspace manifest (no [workspace] table) that also has no [package] table, so there is no package section to inspect. This makes the Cargo.toml unusable for the license/version field check, which needs a concrete package.","triggerScenarios":"package() (via check_and_fix_package_string_field or published) runs on a manifest without [workspace] whose top-level [package] table is missing or is not a TOML table.","commonSituations":"A virtual workspace root manifest ([workspace] only) is handled elsewhere, but a stray Cargo.toml with neither section (e.g. a template or generated file) enters the check; manual edits deleted the [package] table; the wrong file was picked up by the manifest glob.","solutions":["Add the [package] table (with name, version, license, etc.) to the Cargo.toml.","Check the manifest path being processed; a virtual [workspace]-only root must be treated via the workspace branch, not the package branch.","If this file is not a real crate manifest, exclude it from the xtask check's file walk.","Validate the TOML parses as expected: [package] must be a table, not e.g. package = \"...\"."],"exampleFix":"// before: manifest without a package table\n[workspace]\nmembers = [\"crates/*\"]\n\n// after: for a member crate, add the section\n[package]\nname = \"my-crate\"\nversion = \"1.0.0\"\nlicense = \"MIT\"","handlingStrategy":"validation","validationCode":"fn has_package(doc: &toml_edit::DocumentMut) -> bool {\n    doc.as_table().get(\"package\").and_then(|p| p.as_table()).is_some()\n}\n// skip manifests with neither [package] nor [workspace]\nif !has_package(&doc) && doc.as_table().get(\"workspace\").is_none() {\n    return Ok(());\n}","typeGuard":"fn package_table(doc: &toml_edit::DocumentMut) -> Option<&toml_edit::Table> {\n    doc.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().ends_with(\"cannot find package section\") => {\n        eprintln!(\"skipping non-package manifest {}\", cargo_toml.path.display());\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Every crate manifest must contain a [package] table with name, version, and license.","Restrict the xtask manifest glob to real crate manifests, not templates or generated files.","Treat [workspace]-only roots via the workspace branch of the check.","Run a TOML shape validation before field-level checks."],"tags":["cargo","toml","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"}