{"record":{"id":"fee34b9901b73eee","repo":"bevyengine/bevy","slug":"unexpected-length-of-hex-string","errorCode":null,"errorMessage":"Unexpected length of hex string","messagePattern":"Unexpected length of hex string","errorType":"validation","errorClass":"HexColorError","httpStatus":null,"severity":"error","filePath":"crates/bevy_color/src/srgba.rs","lineNumber":439,"sourceCode":"impl From<Srgba> for wgpu_types::Color {\n    fn from(color: Srgba) -> Self {\n        wgpu_types::Color {\n            r: color.red as f64,\n            g: color.green as f64,\n            b: color.blue as f64,\n            a: color.alpha as f64,\n        }\n    }\n}\n\n/// Error returned if a hex string could not be parsed as a color.\n#[derive(Debug, Error, PartialEq, Eq)]\npub enum HexColorError {\n    /// Parsing error.\n    #[error(\"Invalid hex string\")]\n    Parse(#[from] core::num::ParseIntError),\n    /// Invalid length.\n    #[error(\"Unexpected length of hex string\")]\n    Length,\n    /// Invalid character.\n    #[error(\"Invalid hex char\")]\n    Char(char),\n}\n\n#[cfg(test)]\nmod tests {\n    use crate::testing::assert_approx_eq;\n\n    use super::*;\n\n    #[test]\n    fn test_to_from_linear() {\n        let srgba = Srgba::new(0.0, 0.5, 1.0, 1.0);\n        let linear_rgba: LinearRgba = srgba.into();\n        assert_eq!(linear_rgba.red, 0.0);\n        assert_approx_eq!(linear_rgba.green, 0.2140, 0.0001);","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_color/src/srgba.rs#L421-L457","documentation":"HexColorError::Length: the hex color string's length does not match any supported format. Bevy accepts 6-digit RGB and 8-digit RGBA (with optional leading '#'); any other length (e.g. 3, 4, or 7 after '#' handling) yields this error.","triggerScenarios":"Thrown at crates/bevy_color/src/srgba.rs:439 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use '#RRGGBB' or '#RRGGBBAA' format","Expand shorthand forms like '#ABC' to '#AABBCC' before parsing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}