{"record":{"id":"c21097aea63c320f","repo":"Morganamilo/paru","slug":"value-can-not-be-empty-for-key","errorCode":null,"errorMessage":"value can not be empty for key '{}'","messagePattern":"value can not be empty for key '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/config.rs","lineNumber":941,"sourceCode":"            return !(args.has_arg(\"p\", \"print\")\n                || args.has_arg(\"p\", \"print-format\")\n                || args.has_arg(\"s\", \"search\")\n                || args.has_arg(\"l\", \"list\")\n                || args.has_arg(\"g\", \"groups\")\n                || args.has_arg(\"i\", \"info\")\n                || (args.has_arg(\"c\", \"clean\") && !self.mode.repo()));\n        } else if self.op == Op::Upgrade || self.op == Op::Build {\n            return true;\n        }\n\n        false\n    }\n\n    fn parse_directive(&mut self, key: &str, value: Option<&str>) -> Result<()> {\n        if key == \"Include\" {\n            let value = match value {\n                Some(value) => value,\n                None => bail!(tr!(\"value can not be empty for key '{}'\", key)),\n            };\n\n            let ini = std::fs::read_to_string(value)?;\n\n            let section = self.section.clone();\n            let section = section.as_deref();\n            let section = self\n                .parse_with_section(section, Some(value), &ini)?\n                .map(|s| s.to_string());\n            self.section = section;\n            return Ok(());\n        }\n\n        let section = match &self.section {\n            Some(section) => section.as_str(),\n            None => bail!(tr!(\"key '{}' does not belong to a section\", key)),\n        };\n","sourceCodeStart":923,"sourceCodeEnd":959,"githubUrl":"https://github.com/Morganamilo/paru/blob/9ac3578807a87858651e81a02586ceb947686e7c/src/config.rs#L923-L959","documentation":"In this crate's pacman.conf INI parser (src/config.rs:941), parse_directive requires a value for every key it processes. When a directive such as `Include` appears with no value after the `=`, the parser bails with \"value can not be empty for key '{}'\". This is a strict config-validation error: the parser refuses to guess defaults for directives that need an operand (e.g. an Include path pointing at another config fragment).","triggerScenarios":"Calling pacmanconf::Config::expand_with_opts / parse on a pacman.conf (or any file it Includes) that contains a directive with an empty or missing value — e.g. a line reading just `Include` or `Include =` with nothing after the `=`. ParseArg in src/args.rs and chroot setup in src/chroot.rs:29 both funnel through this parser.","commonSituations":"Hand-edited pacman.conf where the value was accidentally deleted; a generated pacstrap/chroot pacman.conf template with a placeholder never filled in; a blank `Include =` line left behind after commenting out a repo; copy-paste truncation of the config line.","solutions":["Open the pacman.conf (and every file it Includes) and give the offending key a value: `Include = /etc/pacman.d/mirrorlist`.","If the directive is unused, delete the entire line or comment it out with `#` instead of leaving an empty value.","Regenerate a known-good pacman.conf (e.g. `pacman-conf` output or distro default /etc/pacman.conf) and re-apply customizations.","Validate the config before use with `pacman-conf` or the crate's parser on a copy so failures are caught early."],"exampleFix":"// before (pacman.conf)\nInclude =\n\n// after (pacman.conf)\nInclude = /etc/pacman.d/mirrorlist","handlingStrategy":"validation","validationCode":"// Pre-validate pacman.conf lines before handing to the parser\nfn validate_no_empty_values(path: &str) -> Result<(), String> {\n    for (n, line) in std::fs::read_to_string(path)?.lines().enumerate() {\n        let line = line.trim();\n        if line.is_empty() || line.starts_with('#') || line.starts_with('[') { continue; }\n        match line.split_once('=') {\n            Some((k, v)) if v.trim().is_empty() => {\n                return Err(format!(\"line {}: empty value for key '{}'\", n + 1, k.trim()))\n            }\n            None => return Err(format!(\"line {}: not key=value: '{}'\", n + 1, line)),\n            _ => {}\n        }\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave `key =` with an empty value; comment out the whole line instead.","Run `pacman-conf` (or the parser on a scratch copy) after every manual pacman.conf edit.","Resolve .pacnew/.pacsave merges carefully — empty lines often come from failed merges.","Keep generated/chroot configs fully templated so placeholders are always substituted."],"tags":["config","ini-parsing","pacman","empty-value"],"backgroundTag":"empty-required-field","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"}