{"record":{"id":"72e63615f4a0b9dd","repo":"denisidoro/navi","slug":"no-variable-captured-in-the-line","errorCode":null,"errorMessage":"No variable captured in the line `{}`","messagePattern":"No variable captured in the line `(.+?)`","errorType":"validation","errorClass":"anyhow","httpStatus":null,"severity":"error","filePath":"src/parser.rs","lineNumber":93,"sourceCode":"        .context(\"Failed to parse finder options\")?;\n\n    let suggestion_type = match (multi, prevent_extra) {\n        (true, _) => SuggestionType::MultipleSelections, // multi wins over prevent-extra\n        (false, false) => SuggestionType::SingleRecommendation,\n        (false, true) => SuggestionType::SingleSelection,\n    };\n    opts.suggestion_type = suggestion_type;\n\n    Ok(opts)\n}\n\nfn parse_variable_line(line: &str) -> Result<(&str, &str, Option<FinderOpts>)> {\n    let caps = VAR_LINE_REGEX\n        .captures(line)\n        .ok_or_else(|| anyhow!(\"No variables, command, and options found in the line `{}`\", line))?;\n    let variable = caps\n        .get(1)\n        .ok_or_else(|| anyhow!(\"No variable captured in the line `{}`\", line))?\n        .as_str()\n        .trim();\n    let mut command_plus_opts = caps\n        .get(2)\n        .ok_or_else(|| anyhow!(\"No command and options captured in the line `{}`\", line))?\n        .as_str()\n        .split(\"---\");\n    let command = command_plus_opts\n        .next()\n        .ok_or_else(|| anyhow!(\"No command captured in the line `{}`\", line))?;\n    let command_options = command_plus_opts.next().map(parse_opts).transpose()?;\n    Ok((variable, command, command_options))\n}\n\nfn without_prefix(line: &str) -> String {\n    // The prefix character (#, %, @) is always 1-byte ASCII.\n    // Skip it and let trim() handle any whitespace separator, including\n    // multi-byte whitespace like non-breaking space (\\u{a0}).","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/denisidoro/navi/blob/f7330b9ad5bd95b7d1a3c96d00e0a77deb589147/src/parser.rs#L75-L111","documentation":"Thrown by `parse_variable_line` in src/parser.rs when `VAR_LINE_REGEX` matched the line but capture group 1 (the variable name) is absent. This is a defensive check: the overall regex matched, yet the variable capture is empty or optional and failed to extract.","triggerScenarios":"A line whose shape mostly matches the variable-line pattern but whose variable name position is empty, e.g. an empty name before the colon such as `: cat file.txt` (prefix with no name) or a malformed prefix the regex skipped.","commonSituations":"Deleting the variable name while editing a config but leaving the `:`; a variable name made only of characters the capture group excludes; truncated first column from a bad copy-paste.","solutions":["Add a valid variable name before the colon","Ensure the variable prefix character (#, %, @) is immediately followed by the name","Re-type the line cleanly to avoid invisible characters breaking the capture"],"exampleFix":"// before\n#: cat file.txt\n// after\n#my-var: cat file.txt","handlingStrategy":"validation","validationCode":"let has_var = |line: &str| {\n    line.split_once(':').map_or(false, |(lhs, _)| {\n        lhs.trim_start_matches(['#', '%', '@']).trim().len() > 0\n    })\n};\n// require has_var(line) before parsing","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave the variable name empty after the prefix character","Re-type lines instead of patching them piecemeal to avoid dropped characters","Run a config lint that flags `prefix:` with no name"],"tags":["parsing","regex","config"],"backgroundTag":"regex-capture-missing","analyzedSha":"f7330b9ad5bd95b7d1a3c96d00e0a77deb589147","analyzedAt":"2026-09-03T13:58:22.429Z","contentChangedAt":"2026-09-03T13:58:22.429Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}