{"record":{"id":"d687a4a3aab2f084","repo":"slint-ui/slint","slug":"missing-field","errorCode":null,"errorMessage":"Missing {} field","messagePattern":"Missing (.+?) field","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/src/license_headers_check.rs","lineNumber":911,"sourceCode":"                                        \"Incorrect {}. Found {} expected {}\",\n                                        field,\n                                        text,\n                                        expected_str\n                                    ));\n                                }\n                            }\n                        }\n                        None => return Err(anyhow!(\"{} field is not a string\", field)),\n                    },\n                };\n            }\n            None => {\n                if fix_it {\n                    eprintln!(\"Fixing up {:?} as instructed. It has no {field}.\", self.path);\n                    self.doc[\"package\"][field] = toml_edit::value(expected_str);\n                    self.edited = true;\n                } else {\n                    return Err(anyhow!(\"Missing {} field\", field));\n                }\n            }\n        };\n        Ok(())\n    }\n\n    fn published(&self) -> Result<bool> {\n        Ok(self.package()?.get(\"publish\").map(|v| v.as_bool().unwrap()).unwrap_or(true))\n    }\n\n    fn save_if_changed(&self) -> Result<()> {\n        if self.edited {\n            std::fs::write(&self.path, self.doc.to_string()).context(\"Error writing new Cargo.toml\")\n        } else {\n            Ok(())\n        }\n    }\n}","sourceCodeStart":893,"sourceCodeEnd":929,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/xtask/src/license_headers_check.rs#L893-L929","documentation":"check_and_fix_package_string_field throws this when the Cargo.toml [package] table has no entry for the checked field at all and the check is not in fix mode. The xtask license-headers check requires certain package metadata fields (license, homepage, repository, ...) on every crate.","triggerScenarios":"Running `cargo xtask check` (no --fix) on a crate whose [package] section is missing e.g. `license`, `homepage`, or `repository`.","commonSituations":"Creating a new crate with cargo init and forgetting required metadata; a crate intentionally kept minimal; deleting a field during refactoring.","solutions":["Run `cargo xtask check --fix` to insert the expected field value automatically","Add the missing field manually with the expected value from xtask/src/license_headers_check.rs (e.g. repository = \"https://github.com/slint-ui/slint\")","If the crate is not meant to be checked, verify it is not unexpectedly part of the workspace"],"exampleFix":"// before\n[package]\nname = \"my-crate\"\nversion = \"0.1.0\"\n// after\n[package]\nname = \"my-crate\"\nversion = \"0.1.0\"\nrepository = \"https://github.com/slint-ui/slint\"","handlingStrategy":"validation","validationCode":"let t: toml::Value = toml::from_str(&std::fs::read_to_string(\"Cargo.toml\")?)?;\nfor field in [\"license\", \"description\", \"repository\", \"homepage\"] {\n    assert!(t[\"package\"].get(field).is_some(), \"missing [package].{field}\");\n}","typeGuard":"fn has_package_field(doc: &toml::Value, field: &str) -> bool {\n    doc[\"package\"].get(field).map_or(false, |v| !v.is_none())\n}","tryCatchPattern":null,"preventionTips":["Use a workspace Cargo.toml template for new crates","Run `cargo xtask check` in a pre-commit hook","Keep required metadata fields listed in the team onboarding docs","Prefer inheriting fields via workspace = true where supported"],"tags":["cargo","cargo-toml","missing-field","ci"],"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"}