{"record":{"id":"8290443478d2989f","repo":"herdrdev/herdr","slug":"failed-to-parse-editor-command-editor","errorCode":null,"errorMessage":"failed to parse editor command {editor:?}","messagePattern":"failed to parse editor command (.+?)","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"src/platform/windows.rs","lineNumber":765,"sourceCode":"pub(crate) fn scrollback_editor_argv(path: &std::path::Path) -> std::io::Result<Vec<String>> {\n    let editor = std::env::var(\"VISUAL\")\n        .ok()\n        .filter(|value| !value.trim().is_empty())\n        .or_else(|| {\n            std::env::var(\"EDITOR\")\n                .ok()\n                .filter(|value| !value.trim().is_empty())\n        });\n    scrollback_editor_argv_with_env(path, editor.as_deref())\n}\n\nfn scrollback_editor_argv_with_env(\n    path: &std::path::Path,\n    editor: Option<&str>,\n) -> std::io::Result<Vec<String>> {\n    let mut argv = match editor.filter(|value| !value.trim().is_empty()) {\n        Some(editor) => command_line_to_argv(editor).ok_or_else(|| {\n            std::io::Error::new(\n                std::io::ErrorKind::InvalidInput,\n                format!(\"failed to parse editor command {editor:?}\"),\n            )\n        })?,\n        None => vec![\"notepad.exe\".to_string()],\n    };\n    if argv.is_empty() {\n        return Err(std::io::Error::new(\n            std::io::ErrorKind::InvalidInput,\n            \"editor command must not be empty\",\n        ));\n    }\n    argv.push(path.display().to_string());\n    Ok(argv)\n}\n\npub(crate) fn configure_background_command_platform(command: &mut std::process::Command) {\n    use std::os::windows::process::CommandExt;","sourceCodeStart":747,"sourceCodeEnd":783,"githubUrl":"https://github.com/herdrdev/herdr/blob/f457cff4f2648eee85d176f8a41861241d4e8428/src/platform/windows.rs#L747-L783","documentation":"When opening scrollback in an editor on Windows, Herdr parses the EDITOR/VISUAL-style command string with command_line_to_argv (Windows command-line splitting rules). If parsing yields None — the string cannot be tokenized into an argv — this InvalidInput error reports the offending editor value.","triggerScenarios":"Calling scrollback_editor_argv (directly or via the open-in-editor action) with an editor string that command_line_to_argv cannot parse: unbalanced quotes, trailing backslashes inside quotes, or other malformed Windows command-line quoting.","commonSituations":"EDITOR set to something like '\"C:\\\\My Editor\\\\v.exe\" -arg' with mismatched quotes; exported from a POSIX shell with escaping mangled (Git Bash/WSL exporting to Windows); trailing backslash before a closing quote.","solutions":["Fix quoting in the editor variable: ensure every opening quote has a closing partner and no stray backslash escapes a closing quote","Simplify the editor command to a single unquoted executable path with no spaces if possible","Quote the whole path once: EDITOR='\"C:\\Program Files\\VS Code\\bin\\code.cmd\"'","Unset EDITOR to fall back to notepad.exe"],"exampleFix":"# before\nEDITOR='\"C:\\\\My Editor\\\\e.exe\"'\n# after\nEDITOR='\"C:\\Program Files\\MyEditor\\e.exe\"'","handlingStrategy":"validation","validationCode":"fn editor_parses(editor: &str) -> bool {\n    // mirror Windows rules: balanced quotes, no dangling backslash-quote\n    let mut in_quotes = false;\n    let chars: Vec<char> = editor.chars().collect();\n    let mut i = 0;\n    while i < chars.len() {\n        match chars[i] {\n            '\"' => in_quotes = !in_quotes,\n            '\\\\' if in_quotes && i + 1 < chars.len() && chars[i + 1] == '\"' => i += 1,\n            _ => {}\n        }\n        i += 1;\n    }\n    !in_quotes\n}","typeGuard":null,"tryCatchPattern":"Err(e) if e.kind() == std::io::ErrorKind::InvalidInput && e.to_string().contains(\"failed to parse editor command\") => {\n    // show the raw editor value to the user and fall back to notepad.exe\n}","preventionTips":["Validate EDITOR/VISUAL quoting when settings are loaded","Warn on editor values containing unbalanced quotes","Default to notepad.exe when parsing fails instead of hard-failing the action"],"tags":["windows","editor","command-line-parsing","quoting","invalid-input"],"backgroundTag":"command-line-quoting-error","analyzedSha":"f457cff4f2648eee85d176f8a41861241d4e8428","analyzedAt":"2026-08-28T15:41:09.197Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}