{"record":{"id":"a65bb6a6b818a143","repo":"slint-ui/slint","slug":"field-is-not-a-string","errorCode":null,"errorMessage":"{} field is not a string","messagePattern":"(.+?) field is not a string","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/src/license_headers_check.rs","lineNumber":901,"sourceCode":"                            if text != expected_str {\n                                if fix_it {\n                                    eprintln!(\n                                        \"Fixing up {:?} as instructed. It has unexpected data in {field}.\",\n                                        self.path\n                                    );\n                                    self.doc[\"package\"][field] = toml_edit::value(expected_str);\n                                    self.edited = true;\n                                } else {\n                                    return Err(anyhow!(\n                                        \"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))","sourceCodeStart":883,"sourceCodeEnd":919,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/xtask/src/license_headers_check.rs#L883-L919","documentation":"check_and_fix_package_string_field throws this when the [package] field exists in Cargo.toml but its parsed value is not a TOML string (e.g. an inline table, array, or other type). The check only knows how to compare/fix string fields.","triggerScenarios":"A Cargo.toml [package] field that should be a string is written as another TOML type, e.g. `license = { file = \"LICENSE\" }` or `homepage = true` — then `item.as_str()` returns None and the None branch errors.","commonSituations":"Copy-pasting metadata syntax (license as table instead of SPDX string); a TOML merge or automated edit replaced the string with a table; typos such as `repository = [\"url\"]`.","solutions":["Edit the Cargo.toml so the field is a plain string, e.g. `license = \"MIT OR Apache-2.0\"` instead of `license = { file = \"...\" }`","Re-run `cargo xtask check` to confirm the field passes","Use `cargo metadata`/`cargo package --list` to spot malformed package fields"],"exampleFix":"// before\nlicense = { file = \"LICENSE\" }\n// after\nlicense = \"MIT OR Apache-2.0\"","handlingStrategy":"validation","validationCode":"let t: toml::Value = toml::from_str(&std::fs::read_to_string(\"Cargo.toml\")?)?;\nif !t[\"package\"][\"license\"].is_str() {\n    panic!(\"license must be a plain SPDX string\");\n}","typeGuard":"fn package_field_is_str(doc: &toml::Value, field: &str) -> bool {\n    doc[\"package\"][field].is_str()\n}","tryCatchPattern":null,"preventionTips":["Always write license as a single SPDX expression string, not a { file = ... } table","Validate Cargo.toml with `cargo package --list` before committing","Avoid TOML merge tools that may convert strings to tables","Lint new crates' Cargo.toml against a template"],"tags":["cargo","cargo-toml","toml","type-mismatch"],"backgroundTag":"config-type-mismatch","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"}