{"record":{"id":"82446a7cc5e16411","repo":"zed-industries/zed","slug":"too-many-arguments","errorCode":null,"errorMessage":"too many arguments","messagePattern":"too many arguments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_context/src/git_log_context.rs","lineNumber":145,"sourceCode":"fn run() -> Result<()> {\n    let mut arguments = env::args_os();\n    let program_name = arguments\n        .next()\n        .and_then(|path| PathBuf::from(path).file_name().map(|name| name.to_owned()))\n        .and_then(|name| name.into_string().ok())\n        .unwrap_or_else(|| \"git_log_context\".to_string());\n\n    let worktree_dir = arguments.next().ok_or_else(|| {\n        print_usage(&program_name);\n        anyhow!(\"missing worktree path\")\n    })?;\n    let query_path = arguments.next().ok_or_else(|| {\n        print_usage(&program_name);\n        anyhow!(\"missing query path\")\n    })?;\n    if arguments.next().is_some() {\n        print_usage(&program_name);\n        bail!(\"too many arguments\");\n    }\n\n    let worktree_dir = PathBuf::from(worktree_dir);\n    let query_path = normalize_query_path(&worktree_dir, &PathBuf::from(query_path));\n    let index = futures::executor::block_on(build_git_log_index(&worktree_dir))?;\n\n    for (path, count) in index.get_related_with_counts(&query_path, 10) {\n        println!(\"{count}\\t{}\", path.display());\n    }\n\n    Ok(())\n}\n\n#[allow(dead_code)]\nfn print_usage(program_name: &str) {\n    eprintln!(\"Usage: {program_name} <worktree-path> <query-path>\");\n}\n","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_context/src/git_log_context.rs#L127-L163","documentation":"Bailed by the git_log_context helper binary's main when it receives more than two positional arguments. The helper accepts exactly `<worktree-path> <query-path>` and no flags; after the first two arguments, any third triggers the usage print plus this error.","triggerScenarios":"Invoking the helper with an extra flag or path, or shell word-splitting turning an unquoted path with spaces into multiple arguments.","commonSituations":"Passing `-n 10` style flags that belong to other tools; unquoted variables in scripts; leftover placeholder arguments.","solutions":["Pass exactly two arguments: the worktree path and the query path","Quote each path as a single shell argument so spaces don't split it","Remove any options — this helper takes none"],"exampleFix":"# before\ngit-log-context /repo 'src/a b.rs' extra\n\n# after\ngit-log-context /repo 'src/a b.rs'","handlingStrategy":"validation","validationCode":"if argv.len() > 2 {\n    // reject before spawning: helper takes exactly <worktree> <query-path>\n}","typeGuard":null,"tryCatchPattern":"Validate the argument count client-side and fail with the usage line before spawning; a spawn that fails this way wastes a process round-trip.","preventionTips":["Build argv arrays explicitly rather than shell strings","Quote paths with spaces as single arguments","Remember the helper accepts no flags — only two positional paths"],"tags":["cli","argument-parsing","git","rust"],"backgroundTag":"invalid-cli-argument","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}