Skip to content

gh search quotes a single-argument query with multiple qualifiers as one qualifier value #13678

Description

@jianongHe

Describe the bug

gh search repos says it supports GitHub search syntax, but when a full search query with multiple qualifiers is passed as one shell argument, gh rewrites it as a single quoted value for the first qualifier.

For example, this query:

gh search repos 'topic:artificial-intelligence stars:>5000 pushed:>2026-06-01 archived:false' --sort updated

is sent to the API as:

topic:"artificial-intelligence stars:>5000 pushed:>2026-06-01 archived:false"

As a result, qualifiers such as stars:>5000, pushed:>2026-06-01, and archived:false are no longer applied as filters.

If this behavior is confirmed as a bug and external contribution would be welcome, I would be happy to send a focused PR with tests.

Affected version

gh version 2.95.0 (2026-06-17)
https://github.com/cli/cli/releases/tag/v2.95.0

Steps to reproduce the behavior

  1. Run:
GH_DEBUG=api gh search repos 'topic:artificial-intelligence stars:>5000 pushed:>2026-06-01 archived:false' --sort updated --limit 1 --json fullName,stargazersCount
  1. Observe that the request URL contains the whole query as the quoted topic: value:
q=topic%3A%22artificial-intelligence+stars%3A%3E5000+pushed%3A%3E2026-06-01+archived%3Afalse%22
  1. Observe that a repository below 5,000 stars can be returned:
[{"fullName":"EalZz/IT-AI-NEWS","stargazersCount":2}]

Expected vs actual behavior

Expected:

The query should preserve the GitHub search syntax:

topic:artificial-intelligence stars:>5000 pushed:>2026-06-01 archived:false

Actual:

The query is rewritten as:

topic:"artificial-intelligence stars:>5000 pushed:>2026-06-01 archived:false"

This makes the later qualifiers part of the topic: value instead of independent filters.

Passing the qualifiers as separate argv entries works:

gh search repos topic:artificial-intelligence 'stars:>5000' 'pushed:>2026-06-01' archived:false --sort updated --limit 1 --json fullName,stargazersCount

Using flags also works:

gh search repos --topic artificial-intelligence --stars '>5000' --updated '>2026-06-01' --archived=false --sort updated --limit 1 --json fullName,stargazersCount

Logs

* Request to https://api.github.com/search/repositories?page=1&per_page=1&q=topic%3A%22artificial-intelligence+stars%3A%3E5000+pushed%3A%3E2026-06-01+archived%3Afalse%22&sort=updated
[{"fullName":"EalZz/IT-AI-NEWS","stargazersCount":2}]

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsenhancementa request to improve CLIgh-searchrelating to the gh search command

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions