Make WordPress Core

Opened 3 months ago

Closed 3 months ago

Last modified 3 months ago

#64175 closed defect (bug) (fixed)

The `in:body` search queries not respected through GitHub's GraphQL API

Reported by: desrosj's profile desrosj Owned by: desrosj's profile desrosj
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

The in:body qualifier 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 state field. Since is:open is 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

This ticket was mentioned in Slack in #core by desrosj. View the logs.


3 months ago

#3 @desrosj
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

#5 @desrosj
3 months ago

  • Owner set to desrosj
  • Resolution set to fixed
  • Status changed from new to closed

In 61100:

Build/Test Tools: Remove in:body from pull request search query.

When searching for pull requests using the GraphQL API, in:body is not being respected in search queries. Because it’s common for Trac tickets to be referenced in the discussions happening in comments and reviews, some pull requests are being closed out incorrectly.

This removes in:body from the search query introduced in [59661] and instead checks the bodyText for references to the fixed tickets.

The state field is also being removed because it is unused.

Props dd32, peterwilsoncc, johnbillion, joedolson, westonruter, dmsnell.
Fixes #64175.

#6 @desrosj
3 months ago

In 61101:

Build/Test Tools: Use the correct syntax for a .filter().

Follow up to [61100].

Props peterwilsoncc.
Fixes #64175.

Note: See TracTickets for help on using tickets.