Skip to content

docs(search): improve search_code query description to prevent 422 errors#2402

Open
Will-hxw wants to merge 1 commit intogithub:mainfrom
Will-hxw:fix/search-code-query-description
Open

docs(search): improve search_code query description to prevent 422 errors#2402
Will-hxw wants to merge 1 commit intogithub:mainfrom
Will-hxw:fix/search-code-query-description

Conversation

@Will-hxw
Copy link
Copy Markdown

Summary

The previous search_code query description gave AI models insufficient guidance on GitHub code search syntax, leading agents to make common mistakes that result in 422 errors.

Changes

Updated the query parameter description in pkg/github/search.go to explicitly document:

  • Qualifiers: repo:, org:, language:, path:, path:/regex/, symbol:, content:, is:
  • Boolean operators: AND, OR, NOT, parentheses
  • Regex syntax: surround with slashes e.g. /foo|bar/
  • Glob patterns in path: path:*.ts, path:/src/**/*.js

Problem examples (from real agent sessions)

These queries all caused 422 ERROR_TYPE_QUERY_PARSING_FATAL:

  • \\"foo\\|bar\\" — used \| for regex OR; correct: /foo|bar/
  • path:docs OR path:.github — surprising precedence without parentheses
  • filename:*review*.md — filename: is not valid; correct: path:*review*.md

Fixes

Fixes #2390

…rors

The previous description gave AI models insufficient guidance on
GitHub code search syntax, leading to common mistakes like:
- Using \| instead of /...|.../ for regex OR
- Confusing filename: with path: qualifiers
- Misunderstanding boolean operator precedence

The new description explicitly documents:
- Qualifiers: repo:, org:, language:, path:, path:/regex/, symbol:, content:, is:
- Boolean operators: AND, OR, NOT, parentheses
- Regex syntax: surround with slashes e.g. /foo|bar/
- Glob patterns in path: path:*.ts, path:/src/**/*.js

Fixes github#2390
@Will-hxw Will-hxw requested a review from a team as a code owner April 28, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

search_code query description teaches incorrect syntax, causing repeated 422 errors

1 participant