{"record":{"id":"a4046f863dfd70d1","repo":"GitoxideLabs/gitoxide","slug":"invalid-pathspec-spec-path-must-not-be-empty","errorCode":null,"errorMessage":"Invalid pathspec {spec} - path must not be empty, not be excluded, and wildcards are taken literally","messagePattern":"Invalid pathspec (.+?) - path must not be empty, not be excluded, and wildcards are taken literally","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitoxide-core/src/query/engine/command.rs","lineNumber":32,"sourceCode":"        &self,\n        cmd: Command,\n        mut out: impl std::io::Write,\n        mut progress: impl gix::NestedProgress,\n    ) -> anyhow::Result<()> {\n        match cmd {\n            Command::TracePath { spec } => {\n                let is_excluded = spec.is_excluded();\n                let relpath = if spec.signature.contains(gix::pathspec::MagicSignature::TOP) {\n                    let root = self.repo.workdir().unwrap_or_else(|| self.repo.git_dir());\n                    let path = root.join(gix::path::from_bstr(spec.path()).as_ref());\n                    self.repo\n                        .normalize_path(gix::path::into_bstr(path).as_ref())?\n                        .into_owned()\n                } else {\n                    self.repo.normalize_path(spec.path())?.into_owned()\n                };\n                if relpath.is_empty() || is_excluded {\n                    bail!(\n                        \"Invalid pathspec {spec} - path must not be empty, not be excluded, and wildcards are taken literally\"\n                    )\n                }\n                let file_id: usize = self\n                    .con\n                    .query_row(\n                        \"SELECT file_id FROM files WHERE file_path = ?\",\n                        params![relpath.to_str_lossy()],\n                        |r| r.get(0),\n                    )\n                    .optional()?\n                    .with_context(|| format!(\"Path '{relpath}' not found anywhere in recorded history\"))?;\n\n                let mut by_file_id = self\n                    .con\n                    .prepare(\"SELECT hash, mode, source_file_id, has_diff, lines_added, lines_removed from commit_file where file_id = ? order by mode\")?;\n                let mut path_by_id = self.con.prepare(\"SELECT file_path from files where file_id = ?\")?;\n                let mut seen = HashMap::<usize, String>::new();","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gitoxide-core/src/query/engine/command.rs#L14-L50","documentation":"Thrown by the repository query engine (`gitoxide_core::query::engine::command::run`) when a pathspec is invalid: the normalized path relative to the repository is empty, or the path is excluded, or it contains wildcards (which are treated literally here). The error includes the offending spec so the user can correct it.","triggerScenarios":"Invoking a query command with a pathspec that (a) normalizes to an empty relative path (e.g. the repo root itself), (b) points to an excluded path (matched by exclusion patterns), or (c) contains glob characters like `*` that this engine does not expand.","commonSituations":"Passing `.` or the repository root as a path; pathspec matching an ignored/excluded file; using shell-style wildcards like `src/*.rs` expecting glob behavior; scripts constructing pathspecs from variables that end up empty.","solutions":["Provide a concrete, non-empty path relative to the repository root instead of `.` or an excluded path","Remove wildcard characters - paths are matched literally","Verify the path is not covered by exclusion patterns in the query configuration","Escape or restructure paths containing `*`, `?`, or `[` characters"],"exampleFix":"// before\ngix repo query --pathspec \"src/*.rs\"\n// after\n# wildcards are literal; list concrete paths instead\ngix repo query --pathspec \"src/main.rs\" --pathspec \"src/lib.rs\"","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = run(/* args */) {\n    if e.to_string().starts_with(\"Invalid pathspec\") {\n        eprintln!(\"pathspec rejected: {e}\");\n    }\n}","preventionTips":["Reject pathspecs with glob metacharacters at the caller level","Ensure pathspecs resolve within the repository and are non-empty"],"tags":["git","pathspec","validation","cli"],"backgroundTag":"invalid-argument-value","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}