#64175 closed defect (bug) (fixed)
The `in:body` search queries not respected through GitHub's GraphQL API
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.9 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Build/Test Tools | Keywords: | has-patch |
| Focuses: | Cc: |
Description
The Cleanup Pull Request workflow in GitHub Actions runs on every push event and searches for pull requests that mention any tickets noted as Fixed in the commit message.
Recently, there have been several pull requests that were closed incorrectly. It appears that a reference to the fixed ticket numbers anywhere on the pull request was being detected, not just in the body.
According to Copilot, this is expected.
That’s expected — the in:body qualifier is part of GitHub’s search syntax used in the web UI and REST Search API, but it’s not a built‑in filter in the GraphQL schema. In GraphQL, there’s no direct equivalent to in:body as a single qualifier. Instead, you need to explicitly request the body field of the PullRequest object and then filter it yourself in your client code, or use the search connection in GraphQL with a query string that includes in:body.
Instead of using a qualifier to control limit where the search can match, the bodyText needs to be returned and searched manually to confirm a match before closing the pull request.
Change History (6)
This ticket was mentioned in PR #10439 on WordPress/wordpress-develop by @desrosj.
3 months ago
#1
This ticket was mentioned in Slack in #core by desrosj. View the logs.
3 months ago
#3
@
3 months ago
- Summary changed from The `in:body` query does not exist in GitHub GraphQL to The `in:body` search queries not respected through GitHub's GraphQL API
Actually, the description here is incorrect. It is not supported outside of a search query, but it should work within one. For some reason it is not being respected for search queries in GraphQL.
Regardless, the changes in the PR are the best way to fix this until that can be sorted out upstream.
@peterwilsoncc commented on PR #10439:
3 months ago
#4
I've posted a comment in one of my own PRs to see if this works as expected https://github.com/WordPress/wordpress-develop/pull/10438#issuecomment-3470904933
The
in:bodyqualifier does not exist in GraphQL, only in GitHub's search syntax.This adds a
.filter()before mapping the pull request numbers to the variable that is returned. The filter checks for the presence of the (case insensitive) needles within the pull request's body text, which helps filter out any instances where a Trac ticket is referenced within a comment or PR review.This also removes the
statefield. Sinceis:openis in the search query, all returned pull requests will be open making the state is unnecessary.Trac ticket: https://core.trac.wordpress.org/ticket/64175