slint-ui/slint · error
Missing field
Error message
Missing {} field What it means
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.
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
Example fix
// before [package] name = "my-crate" version = "0.1.0" // after [package] name = "my-crate" version = "0.1.0" repository = "https://github.com/slint-ui/slint"
Defensive patterns
Strategy: validation
Validate before calling
let t: toml::Value = toml::from_str(&std::fs::read_to_string("Cargo.toml")?)?;
for field in ["license", "description", "repository", "homepage"] {
assert!(t["package"].get(field).is_some(), "missing [package].{field}");
} Type guard
fn has_package_field(doc: &toml::Value, field: &str) -> bool {
doc["package"].get(field).map_or(false, |v| !v.is_none())
} Prevention
- 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
When it happens
Trigger: Running `cargo xtask check` (no --fix) on a crate whose [package] section is missing e.g. `license`, `homepage`, or `repository`.
Common situations: Creating a new crate with cargo init and forgetting required metadata; a crate intentionally kept minimal; deleting a field during refactoring.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- Missing description field
- Incorrect . Found expected
- cargo failed
- dev-dependencies cannot be from the workspace because…
- field is not a string
AI-assisted analysis of slint-ui/slint@3a7e700487 (2026-09-16).
Data as JSON: /api/errors/d687a4a3aab2f084.
Report an issue: GitHub.
Appendix: source
Thrown at xtask/src/license_headers_check.rs:911
"Incorrect {}. Found {} expected {}",
field,
text,
expected_str
));
}
}
}
None => return Err(anyhow!("{} field is not a string", field)),
},
};
}
None => {
if fix_it {
eprintln!("Fixing up {:?} as instructed. It has no {field}.", self.path);
self.doc["package"][field] = toml_edit::value(expected_str);
self.edited = true;
} else {
return Err(anyhow!("Missing {} field", field));
}
}
};
Ok(())
}
fn published(&self) -> Result<bool> {
Ok(self.package()?.get("publish").map(|v| v.as_bool().unwrap()).unwrap_or(true))
}
fn save_if_changed(&self) -> Result<()> {
if self.edited {
std::fs::write(&self.path, self.doc.to_string()).context("Error writing new Cargo.toml")
} else {
Ok(())
}
}
}View on GitHub (pinned to 3a7e700487)