slint-ui/slint · error
Incorrect . Found expected
Error message
Incorrect {}. Found {} expected {} What it means
This error is thrown by check_and_fix_package_string_field in xtask's license-headers check when a [package] field in a Cargo.toml (e.g. license, homepage, repository) contains a value that differs from the expected canonical string and the check was not run in fix mode. It enforces repo-wide consistency of package metadata.
Solutions
- Run `cargo xtask check --fix` so check_and_fix_package_string_field rewrites the field to the expected value automatically
- Manually edit the [package] field in the offending Cargo.toml to match the expected string exactly
- Check the EXPECTED_* constants in xtask/src/license_headers_check.rs to see the accepted value
Example fix
// before (Cargo.toml) license = "Apache-2.0/MIT" // after license = "MIT OR Apache-2.0"
Defensive patterns
Strategy: validation
Validate before calling
let t: toml::Value = toml::from_str(&std::fs::read_to_string("Cargo.toml")?)?;
let actual = t["package"]["license"].as_str().unwrap_or_default();
assert_eq!(actual, "MIT OR Apache-2.0", "license field mismatch"); Type guard
fn is_expected_field(doc: &toml::Value, field: &str, expected: &str) -> bool {
doc["package"][field].as_str() == Some(expected)
} Prevention
- Run `cargo xtask check` locally before committing
- Copy [package] metadata from an existing crate when creating new ones
- Never hand-edit canonical fields like license/repository; use --fix
- Keep Cargo.toml formatting minimal to avoid stray whitespace differences
When it happens
Trigger: Running `cargo xtask check` (license-headers check without --fix) on a crate whose Cargo.toml [package] field, e.g. license = "MIT", does not exactly equal the expected constant like "MIT OR Apache-2.0" or the expected repository URL.
Common situations: Adding a new crate with hand-written Cargo.toml metadata; copying Cargo.toml from another project; a field having extra whitespace or a differently formatted URL; license expression spelled differently (e.g. "Apache-2.0/MIT").
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Missing description field
- Missing field
- 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/7bf575a810ac5dcc.
Report an issue: GitHub.
Appendix: source
Thrown at xtask/src/license_headers_check.rs:892
} else {
return Err(anyhow!(
"Incorrect {}.workspace found: expected true, found false",
field,
));
}
}
None => match field_value.as_str() {
Some(text) => {
if text != expected_str {
if fix_it {
eprintln!(
"Fixing up {:?} as instructed. It has unexpected data in {field}.",
self.path
);
self.doc["package"][field] = toml_edit::value(expected_str);
self.edited = true;
} else {
return Err(anyhow!(
"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 {View on GitHub (pinned to 3a7e700487)