CommandCodeAI / CommandCodeAI/command-code

grep tool passes empty file type to ripgrep

未关闭 适合新手
#655 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
没有语言数据
星标
4k
派生
350
PR 合并指标
30 天内没有已合并 PR

描述

I asked Command Code to search my project log files for errors using its built-in search tools. Command Code invoked its grep tool, but the search failed before it searched anything.

What I expected

When I ask Command Code to search matching log files with a pattern such as:

  • Glob: **/*.log
  • Pattern: error|exception|failed|failure|fatal|critical|warning|stack trace|traceback

I expect Command Code's search tool to search the matching files. If no file type is selected, the tool should search based on the glob alone.

What happened

Command Code's grep tool returned:

grep: rg: unrecognized file type:

This indicates that the tool is passing an empty type value to ripgrep, effectively invoking something like:

rg --type '' ...

Command Code also tried using type: "text", which returned:

grep: rg: unrecognized file type: text

text is not a registered ripgrep file type.

I did not run grep, rg, or the file search manually. Command Code invoked the search tool as part of handling my request.

How to reproduce

  1. Run Command Code 1.14.0 on macOS.
  2. Ask Command Code to search project log files for errors.
  3. Command Code invokes the built-in grep tool with a valid project path, glob: "**/*.log", and an error pattern.
  4. Leave the file type empty or unset.
  5. Observe rg: unrecognized file type:.
  6. Setting the type to text produces rg: unrecognized file type: text instead.

Environment

  • Command Code: 1.14.0
  • macOS 26.4, ARM64
  • zsh (/bin/zsh)

Workaround

Command Code worked around the problem by using its glob tool to locate log files and then opening the files individually with read_file. That worked, but it is inconvenient for large or numerous log files and does not provide the normal search/context behavior.

I was asking Command Code to investigate real application failures in the logs, including database connection errors, missing database tables, missing PHP classes, an unknown ActiveRecord property, and audit-log schema errors. I have not included any credentials or tokens that were present in those logs.

Possible fix

The type field should be optional, and an empty value should not be passed to ripgrep. The tool could also validate file types against ripgrep's registered types and return a clear validation error for unsupported values.

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从内置 grep 工具的实现以及构建其 ripgrep 参数的入口点开始。使用 glob 和未设置的 type 重现该问题,然后验证不会传入空的 type,并且不支持的 type 会收到明确的错误。运行 grep 工具现有的测试(如果有),并为这两种情况添加覆盖测试。

由索引模型根据 Issue 内容生成。

评估

技术栈
cli
领域
cli, tooling
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
活跃
描述清晰度
基本清楚
新手友好度
68/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。