{"record":{"id":"57bcbe4001f15f83","repo":"Morganamilo/paru","slug":"invalid-value-val-for-key-key-expected-exp","errorCode":null,"errorMessage":"invalid value '{val}' for key '{key}', expected: {exp}","messagePattern":"invalid value '(.+?)' for key '(.+?)', expected: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/config.rs","lineNumber":178,"sourceCode":"    fn default_or(self, key: &str, value: Option<&str>) -> Result<Self> {\n        value.map_or(Ok(self), |value| ConfigEnum::from_str(key, value))\n    }\n\n    fn from_str(key: &str, value: &str) -> Result<Self> {\n        let val = Self::VALUE_LOOKUP\n            .iter()\n            .find(|(name, _)| name == &value)\n            .map(|(_, res)| *res);\n\n        if let Some(val) = val {\n            Ok(val)\n        } else {\n            let okvalues = Self::VALUE_LOOKUP\n                .iter()\n                .map(|v| v.0)\n                .collect::<Vec<&str>>()\n                .join(\"|\");\n            bail!(tr!(\n                \"invalid value '{val}' for key '{key}', expected: {exp}\",\n                val = value,\n                key = key,\n                exp = okvalues\n            ))\n        }\n    }\n}\n\ntype ConfigEnumValues<T> = &'static [(&'static str, T)];\n\n#[derive(Debug, SmartDefault, PartialEq, Eq)]\npub enum Sign {\n    #[default]\n    No,\n    Yes,\n    Key(String),\n}","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/Morganamilo/paru/blob/9ac3578807a87858651e81a02586ceb947686e7c/src/config.rs#L160-L196","documentation":"This is an enum-deserialization failure raised from ConfigEnum::from_str (src/config.rs), a generic validation helper used when a config value must map onto a fixed set of enum variants. The helper looks the raw string up in VALUE_LOOKUP (a static table of accepted name -> variant pairs); when the name is absent, it builds the '|'-joined list of valid names from the same table and bails with this error. It fires while loading or validating the configuration file: the input at fault is the string value assigned to the given key, which is neither a recognized variant name (case is compared exactly) nor otherwise convertible. The message deliberately includes the expected alternatives so the user can correct the config without reading the source.","triggerScenarios":"Setting a config key (or `--sortby`/`--searchby` option) to an unrecognized string, e.g. `--searchby slug` when only name/desc/etc. are valid, or `SortBy = downloads` in paru.conf with a misspelled value.","commonSituations":"Typoed values in paru.conf; values copied from other AUR helpers with different vocabularies; case-sensitivity issues (`Name` vs `name`).","solutions":["Use one of the values listed after 'expected:' in the error message","Fix the spelling/case of the value in the config file or CLI flag","Check documentation for the valid enum values for the key"],"exampleFix":"// before\nSortBy = popularity  // invalid\n// after\nSortBy = votes  // one of the values in the 'expected:' list","handlingStrategy":"validation","validationCode":"function validate_enum(key: string, value: string, lookup: readonly string[]): string | null {\n  return lookup.includes(value) ? null : `invalid value '${value}' for '${key}', expected: ${lookup.join('|')}`;\n}","typeGuard":"function isValidSortBy(v: string): v is 'name' | 'votes' | 'popularity' | 'modified' {\n  return ['name', 'votes', 'popularity', 'modified'].includes(v);\n}","tryCatchPattern":"match ConfigEnum::from_str(key, value) {\n    Err(e) if e.to_string().contains(\"invalid value\") => {\n        eprintln!(\"{} — fix the value in paru.conf\", e);\n        std::process::exit(1);\n    }\n    Err(e) => return Err(e),\n    Ok(v) => apply(v),\n}","preventionTips":["Copy enum values from the error's 'expected:' list verbatim","Keep a linted paru.conf template with only valid values","Match case exactly — enums are usually lowercase"],"tags":["config","enum","validation","parse-error"],"backgroundTag":"invalid-enum-value","analyzedSha":"9ac3578807a87858651e81a02586ceb947686e7c","analyzedAt":"2026-09-12T04:57:59.861Z","contentChangedAt":"2026-09-12T04:57:59.861Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}