Repository navigation
Description
Describe the bug
A keyword in double quotes, as in GitHub's search syntax, reaches the API with its quotes escaped, so the search finds nothing. The escaping is the %q in quote().
This is one term in its own argument, not several qualifiers in one argument as in #13678.
Affected version
gh version 2.104.0 (2026-11-12) | MINGW64_NT-10.0-26300 3.6.10-5a1665c8.x86_64 x86_64
Windows 11, Git Bash.
Steps to reproduce the behavior
Reproducer: https://gist.github.com/YevheniiKotyrlo/772e3d949fafb16beaea0c86c7598aeb (bash repro.sh [path to gh]; the script exits 1 while the bug shows). It runs, against cli/cli:
gh search code '"formatKeywords"' --repo cli/cli --limit 10 --json path --jq lengthprints0.gh search code formatKeywords --repo cli/cli --limit 10 --json path --jq lengthprints1.gh api -X GET search/code -f q='"formatKeywords" repo:cli/cli' --jq .total_countprints1.GH_DEBUG=api gh search code '"formatKeywords"' --repo cli/cli --limit 1requestsq=%22%5C%22formatKeywords%5C%22%22+repo%3Acli%2Fcli.
Expected vs actual behavior
Expected: the quoted keyword reaches the API as typed, q="formatKeywords" repo:cli/cli, and finds what gh api finds for that query (1 result).
Actual: q="\"formatKeywords\"" repo:cli/cli, 0 results.
Logs
Output of bash repro.sh with gh 2.104.0:
$ gh search code '"formatKeywords"' --repo cli/cli --limit 10 --json path --jq length
0
$ gh search code formatKeywords --repo cli/cli --limit 10 --json path --jq length
1
$ gh api -X GET search/code -f q='"formatKeywords" repo:cli/cli' --jq .total_count
1
$ GH_DEBUG=api gh search code '"formatKeywords"' --repo cli/cli --limit 1 (request line)
/search/code?page=1&per_page=1&q=%22%5C%22formatKeywords%5C%22%22+repo%3Acli%2Fcli
q (decoded): "\"formatKeywords\"" repo:cli/cli
SUMMARY: DEFECT: gh search code '"formatKeywords"' --repo cli/cli sent q="\"formatKeywords\"" repo:cli/cli and returned 0 results; gh api with q="formatKeywords" repo:cli/cli returns total_count 1
Activity
cli-triage commentedon Nov 14, 2026
Reproducible on 2.104.0.
Using test data, the quoted keyword produced the reported request encoding:
Exit status:
0.The search command sent
q="\"formatKeywords\"", while the equivalentgh apicommand sentq="formatKeywords"unchanged. Release 2.104.0 and source buildsource-3d5a9e3behaved the same. The zero result used configured data; the confirmed defect is the extra escaping in the outgoing query.gh apiis a workaround for exact quoted terms.Supporting reports
Duplicate analysis
Label reasoning
Reproduction log
Investigation notes
Generated by issue triage.
Daiyuanranfeng commentedon Nov 16, 2026
I would like to take this issue. I will trace the search query quoting path, preserve literal quotes for a single search term while retaining qualifier handling, and add regression coverage for the API query sent by gh search code.