{"record":{"id":"10f3515aa0860680","repo":"emilk/egui","slug":"failed-to-parse-err","errorCode":null,"errorMessage":"Failed to parse {}: {err}","messagePattern":"Failed to parse (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/egui_kittest/src/config.rs","lineNumber":123,"sourceCode":"            } else {\n                format!(\"{section}.\")\n            };\n            log::warn!(\n                \"`{prefix}failed_pixel_count_threshold` in kittest.toml is deprecated; \\\n                 use `{prefix}max_failed_pixels` instead.\"\n            );\n        }\n    }\n}\n\nfn load_config() -> Config {\n    if let Ok(config_path) = find_kittest_toml() {\n        match std::fs::read_to_string(&config_path) {\n            Ok(config_str) => {\n                warn_about_deprecated_keys(&config_str);\n                match toml::from_str(&config_str) {\n                    Ok(config) => config,\n                    Err(err) => panic!(\"Failed to parse {}: {err}\", config_path.display()),\n                }\n            }\n            Err(err) => {\n                panic!(\"Failed to read {}: {}\", config_path.display(), err);\n            }\n        }\n    } else {\n        Config::default()\n    }\n}\n\n/// Get the global configuration.\n///\n/// See [`Config::global`] for details.\npub fn config() -> &'static Config {\n    Config::global()\n}\n","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/emilk/egui/blob/441971a776322a482e371775219380eca812cfa9/crates/egui_kittest/src/config.rs#L105-L141","documentation":"kittest loads an optional `kittest.toml` config file found near the test (via `find_kittest_toml`). If the file exists but fails TOML deserialization into the config struct (syntax error, unknown/wrong-typed keys), `toml::from_str` returns Err and the test panics with the file path and the TOML error.","triggerScenarios":"Having a `kittest.toml` with invalid TOML syntax (unclosed string/table) or a field whose type doesn't match the config struct (e.g. `threshold = \"0.5\"` instead of a number), or a misspelled key not handled by serde (unless unknown keys are allowed).","commonSituations":"Hand-editing kittest.toml and introducing a typo; upgrading kittest where config keys were renamed/deprecated (note `warn_about_deprecated_keys` runs first, but removed keys still break parsing); copying a config from docs with different types.","solutions":["Read the TOML error in the panic — it names the offending line/key — and fix the syntax or value type in that file.","Validate the TOML with any TOML parser/linter (e.g. `taplo`) before committing.","Check for deprecated keys the warning mentions and migrate them to current names.","Ensure value types match the expected schema (numbers unquoted, booleans as true/false, tables with correct nesting).","Temporarily rename/remove kittest.toml to confirm it is the failing file, then rebuild the config incrementally."],"exampleFix":"// kittest.toml\n// before\nthreshold = \"0.5\"   # string, expected number\nsnap = \"yes\"\n// after\nthreshold = 0.5\nsnap = true","handlingStrategy":"validation","validationCode":"// validate kittest.toml before running tests\nlet raw = std::fs::read_to_string(\"kittest.toml\")?;\nlet parsed: Result<toml::Value, _> = toml::from_str(&raw);\nassert!(parsed.is_ok(), \"kittest.toml invalid: {:?}\", parsed.err());","typeGuard":null,"tryCatchPattern":"// when loading configs yourself, avoid panicking:\nmatch toml::from_str::<KittestConfig>(&raw) {\n    Ok(cfg) => cfg,\n    Err(err) => { eprintln!(\"bad kittest.toml: {err}\"); KittestConfig::default() }\n}","preventionTips":["Lint kittest.toml with a TOML tool (e.g. taplo) in CI.","Match key names and value types to the kittest version's config struct; check the changelog when upgrading.","Migrate keys flagged by warn_about_deprecated_keys immediately.","Commit a known-good kittest.toml template and edit incrementally, running tests after each change."],"tags":["toml","config","parsing","panic"],"backgroundTag":"schema-validation-failed","analyzedSha":"441971a776322a482e371775219380eca812cfa9","analyzedAt":"2026-09-12T04:29:21.500Z","contentChangedAt":"2026-09-12T04:29:21.500Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}