Morganamilo/paru · error
invalid value ' ' for key ' ', expected
Error message
invalid value '{val}' for key '{key}', expected: {exp} What it means
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.
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
Example fix
// before SortBy = popularity // invalid // after SortBy = votes // one of the values in the 'expected:' list
Defensive patterns
Strategy: validation
Validate before calling
function validate_enum(key: string, value: string, lookup: readonly string[]): string | null {
return lookup.includes(value) ? null : `invalid value '${value}' for '${key}', expected: ${lookup.join('|')}`;
} Type guard
function isValidSortBy(v: string): v is 'name' | 'votes' | 'popularity' | 'modified' {
return ['name', 'votes', 'popularity', 'modified'].includes(v);
} Try / catch
match ConfigEnum::from_str(key, value) {
Err(e) if e.to_string().contains("invalid value") => {
eprintln!("{} — fix the value in paru.conf", e);
std::process::exit(1);
}
Err(e) => return Err(e),
Ok(v) => apply(v),
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Typoed values in paru.conf; values copied from other AUR helpers with different vocabularies; case-sensitivity issues (`Name` vs `name`).
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
AI-assisted analysis of Morganamilo/paru@9ac3578807 (2026-09-12).
Data as JSON: /api/errors/57bcbe4001f15f83.
Report an issue: GitHub.
Appendix: source
Thrown at src/config.rs:178
fn default_or(self, key: &str, value: Option<&str>) -> Result<Self> {
value.map_or(Ok(self), |value| ConfigEnum::from_str(key, value))
}
fn from_str(key: &str, value: &str) -> Result<Self> {
let val = Self::VALUE_LOOKUP
.iter()
.find(|(name, _)| name == &value)
.map(|(_, res)| *res);
if let Some(val) = val {
Ok(val)
} else {
let okvalues = Self::VALUE_LOOKUP
.iter()
.map(|v| v.0)
.collect::<Vec<&str>>()
.join("|");
bail!(tr!(
"invalid value '{val}' for key '{key}', expected: {exp}",
val = value,
key = key,
exp = okvalues
))
}
}
}
type ConfigEnumValues<T> = &'static [(&'static str, T)];
#[derive(Debug, SmartDefault, PartialEq, Eq)]
pub enum Sign {
#[default]
No,
Yes,
Key(String),
}View on GitHub (pinned to 9ac3578807)