Repository navigation
Description
Describe the bug
When using gh issue list --state all --search with OR operators, the command incorrectly searches across multiple repositories instead of limiting the search to the current repository context.
This only happens in this exact combination, e.g. not with AND
This seems very weird and might possibly show issues I should not have access to, but I am neither able to nor interested in reverse engineering this to find out.
Affected version
gh version 2.79.0 (2025-09-08)
https://github.com/cli/cli/releases/tag/v2.79.0
Steps to reproduce the behavior
- Navigate to any repository directory
- Run: gh issue list (shows ~30 issues for me, highest 133, shown in logs below)
- Run: gh issue list --state all --search "gui OR architecture OR refactor OR event" --limit 20 (also works with other combinations, shown in logs below)
Expected vs actual behaviour
Expected:
Should return only issues from the current repository that match the search criteria.
Actual:
- Returns ~1.8M total issues
- Includes issues from other repositories with titles unrelated to current repo
- Shows impossible duplicate issue numbers (multiple 1s, 20s, etc.)
- Example: Issue 20 shows "Architectural: Refactor Application to Microservices Architecture" but actual repo issue 20 is "Detection of which template to use for document creation is not working"
Logs
(Edited to remove excessive whitespace from table shown in terminal)
-
Normal output from issue listing:
gh issue list
Showing 30 of 36 open issues in Tommynem/VaWW
ID TITLE ...
133 [FEATURE] Integrate is_firm boolean into the filter menu ...
129 [BUG] Fields highlighter uses non-existent border_color to highlight errors ...
128 [FEATURE] Variable amounts of test data generated ... -
Broken command:
gh issue list --state all --search "gui OR architecture OR refactor OR event" --limit 20
Showing 20 of 1845031 issues in Tommynem/VaWW that match your search
ID, TITLE, ...
105 Architecture: Split EventHandler into domain-specific modules ...
2 Refactor architecture ...
1124 REF/GUI: General refactors of GUI and GUI testing ...
...
1 Refactor monolithic architecture into modular components
1 Refactor application to MVC architecture
(There are a lot of duplicates, clearly from different repos if the 1.8M entries didnt give it away)
Edit: removed hashtags from issue numbers to stop GitHub from automatically associating them with actual issues from this repo.
Activity
trishanu-init commentedon Oct 4, 2025
Hi, I would like to work on this issue.
jsoref commentedon Oct 20, 2025
@trishanu-init please don't wait for someone to say "go ahead", just make a PR.
Fwiw, here's my attempt at trying to help a colleague with something which appears to be this bug (note that in this directory,
git remote get-url origin= https://github.com/check-spelling/check-spelling/ (or some equivalent)):From my perspective, there are many bugs here:
Showing 30 of 2461 issues in check-spelling/check-spelling that match your searchis false -- if for any reason the results include more than one repository, the heading should not mention a repository. For the record, https://github.com/check-spelling/check-spelling/issues?q=is%3Aissue has <100 items (and https://github.com/check-spelling/check-spelling/pulls?q=is%3Apr has <10 items) collectively there are fewer than 100 items. (At least one of the two searched users is somewhat prolific across GitHub.)-R ..., unless the search text itself explicitly begs fororg:orrepo:, the search shouldn't extend beyond the selected repository.()[-]gh issue list --state all --search with OR operators searches across multiple repositories instead of current repo[/-][+]`gh issue list --state all --search` with `OR` operators searches across multiple repositories instead of current repo[/+]trishanu-init commentedon Oct 21, 2025
@jsoref since you have linked a PR for the 1st point i will look into the rest 2 and try to resolve them, Thanks
jsoref commentedon Oct 21, 2025
@trishanu-init actually I only covered the last point. But yes, please and thanks!
babakks commentedon Oct 22, 2025
Thanks for reporting this issue, @Tommynem! 🙏 Also thanks for your investigations, @jsoref and @trishanu-init! 🍻
While we appreciate our community taking the initiative to help us ❤️, we also expect contributors to follow our contribution guidelines and processes. Opening a PR before an issue is fully triaged is discouraged because the expectations/requirements of changes are not yet clear (e.g. sometimes internal comms needed, or due to some reasons maintainers would decide the issue is not meant to be picked up by external contributors). These guidelines are in place because we deeply respect our community's time and efforts; opening a PR before an issue is triaged risks a contributor's time being wasted as it may not be accepted for reasonings not readily apparent to an external contributor.
As a bit of context, since
v2.79.0,ghuses the Advanced Issue Search backend for searching issues and PRs. Prior to this, there was noORoperator and therefore combining the user's search query (provided via the--searchoption) with the automatically-added scoping qualifiers (i.e.repo:orstate:) was a correct approach. Now, it clearly needs to be fixed (See my notes below).As for the PR, @jsoref, I have reviewed it, and it's in the right direction. However, we still need more investigations, especially regarding more intricate/advanced queries. I'm going to close the PR since it's not going to be the complete fix we're hoping for.
Temporary workaround
As a temp workaround, enclosing the search query with brackets should block the unwanted mixing:
gh issue list --search '(author:johndoe OR author:janedoe)'Notes on potential fix
This is due the mixing of user search query and the auto-added scoping qualifiers. Regarding the problems @jsoref mentioned above, I believe fixing the third one is the only fix we should need. Once the scoping qualifiers are correctly added (i.e. not mixed with the rest of the final query), the results won't include hits from other repositories.
As the advanced syntax supports grouping of nested queries, one simple fix could be to enclose the user's query in brackets. This'll prevent unexpected mixing of qualifiers. We need to make sure this is not going to break other use cases in any way.
A few things we might want to consider here are:
\, then the rendered\)will be parsed as a escaped char and the mixing will still happen. As I checked this with @BagToad it seems like the API ignores such cases, but at the same time the behaviour seems to be a bit flaky. Definitely, something to investigate a bit more.We probably need internal comms with other engineers for confirmation.
Also, the advanced issue search backend is used in the commands below. So we should make sure the fix applies to all of them.
issue list(this issue)pr listsearch issuessearch prsjsoref commentedon Oct 22, 2025
I'd be inclined to change the wrap in this form:
That'd mean at worst case a trailing
\would escape a spaceinstead of the).A quick check shows that the server side already has code for:
So unless there's some other horrible escape handling for the other stanzas, if someone includes an unbalanced extra
(in their query, it would just trigger a server error.jsoref commentedon Oct 22, 2025
currently, the same bug appears using:
GH_DEBUG=api gh -R check-spelling/check-spelling pr list -S ' author:kylo252 OR author:Sin-Estres-dev ' -s alland would go away with:
GH_DEBUG=api gh -R check-spelling/check-spelling pr list -S '( author:kylo252 OR author:Sin-Estres-dev )' -s allUnrelated (someone can file an issue for this, I'm disinclined at this time), but
searchis pretty buggy:GH_DEBUG=api gh search prs ' author:Sin-Estres-dev 'Note that
()wrapping forsearch prsworks (again, spaces break everything--see above):GH_DEBUG=api gh search -R check-spelling/check-spelling prs '(author:Sin-Estres-dev)'Similarly, spaces break
search issues.these work:
I suppose you have automated stats to have a sense of how many
ghclients are sending the garbage generated queries based on the regression from GitHub CLI 2.79.0. From my perspective this regression cost me enough time that I spent time looking into it (our automatic tools relied on this stuff not being broken).babakks commentedon Oct 22, 2025
I'm sorry that has caused you problems, @jsoref 🙏, but at the
ghside we had no choice but to switch to the advanced syntax, since the old backend is going out of service. Hopefully, we can get around the problems and stabilise the user experience.The commands that use the search API certainly need to be improved, especially with the new advanced syntax and its colorful syntax features. That's why I'm wondering if we might want to do a lightweight parsing of the user queries at the client side.
One more reason is even budging whitespace into the enclosed query will not be the end of the story. Haven't yet tested it, but what happens if the query ends with a double-quote? Does that make the rest of the final query part of a quoted text? 🤷 On the other hand, getting
ghinvolved in such details just makesghmaintenance harder, and prone to future incompatibility as the search syntax evolves. So, it's an intricate situation that requires thorough investigations.jsoref commentedon Oct 22, 2025
Two cases:
Query is broken with no error reporting
Query is broken with horrible error reporting
Seems to be an incredibly horrible error message.
jsoref commentedon Oct 22, 2025
I can't actually find a reference for GitHub's username rules. The closest I can find are for GHES (?):
https://docs.github.com/en/[email protected]/admin/managing-iam/iam-configuration-reference/username-considerations-for-external-authentication#about-username-normalization
Given that a
"is clearly not in that range, someone is being silly trying to treat it as a valid character for anauthor:...search -- offhand, given that it's a server side error, I blame the server. But I do not have the energy to try to file a ticket against the server, GitHub has not treated my tickets well so it's a bad use of my time.babakks commentedon Nov 18, 2025
We decided to move forward with adding the brackets, as it seems to be the right approach at the moment. Involving
ghin parsing the query syntax is just a can of worms, as this is the responsibility of the user to provide a valid query.I also noted that the
issue list --webneeds to be fixed as well. Here it concatenates the user query and the compiled sequence of qualifiers out of thesearchpackage:cli/pkg/cmd/pr/shared/params.go
Lines 227 to 237 in 680a8c4
jsoref commentedon Nov 18, 2025
Are you going to do it yourself, or are you now open to someone else doing it?
babakks commentedon Nov 18, 2025
The change would affect a shared search component used by almost all commands, hence I need to cover various scenarios. It's not a clear case, so it's best to be handled internally.
babakks commentedon Nov 20, 2025
This is fixed now. Thanks again for your investigations and patience! 🍻
Please feel free to try building
ghfrom thetrunkbranch (runmake) and give it a go, @jsoref @trishanu-init @Tommynem.babakks commentedon Dec 11, 2025
Fix is now available in the latest release,
v2.83.2.eMPee584 commentedon Jan 9, 2026
Casually strolling by, wanting to open an issue to have an option for
gh search issuesto automatically search the current repo instead of manually specifying it with-R, only here did I discover the non-obviousissue list --searchsyntax. Guessissue searchwould be difficult to implement as a more intuitive way for search, right? 😅babakks commentedon Jan 9, 2026
@eMPee584, that's a fair suggestion, but the problem is it'll be a breaking change if
search issuesscope to the current repo by default.eMPee584 commentedon Jan 10, 2026
That's why I proposed an option.. but having
gh issue searchwork would be higher up the list.There are more cases like this where synonyms being aliased could improve UX, f.e.
issue showfor alias toissue view.. No idea how to implement that though, or would have sent a PR ..