Returning incorrect customer data in getCustomerByEmailOrPhone query mutation

I was getting incorrect customer data based on provided email or phone number in between Oct 20 to 24 Oct 2025. It was providing wrong customer data if new email is provided with empty phone number. Was there any technical glitch that has been fixed?

query getCustomerByEmailOrPhone($query: String!) {
customers(first: 1, query: $query) {
edges {
node {
id
firstName
lastName
email
phone
emailMarketingConsent {
marketingState
marketingOptInLevel
consentUpdatedAt
}
smsMarketingConsent {
marketingState
marketingOptInLevel
consentUpdatedAt
}
}
}
}
}

Hey @Usman_Manzoor, we’re not aware of any incidents or changes during that timeframe that would have affected customer query results.

To help us investigate what happened, can you share more details on the variables you used? Specifically the query parameter in your customers search. For example, were you using something like "query": "email:customer@example.com" or a different format?

If you have it as well, an x-request-id from a response headers that returned unexpected customer data. With a request ID, I may be able to locate the events of these queries in our logs.

I am still able to reproduce this issue. I am facing this issue on specific stores.

query: ‘email:customer@example.com OR phone:’

Query mutation is shared in above post. I am using api version 2025-07.

Response from Shopify:

[
{
node: {
id: ‘gid://shopify/Customer/xyz’,
firstName: ‘xyz’,
lastName: ‘xyz’,
email: ‘xyz’,
phone: null,
emailMarketingConsent: [Object],
smsMarketingConsent: null
}
}
]

Hey @Usman_Manzoor, the issue is with your query syntax. The phone: parameter doesn’t have a value:

'email:customer@example.com OR phone:'

You can see exactly what’s happening by using the search query debugging header. Add this header to your request:

Shopify-Search-Query-Debug: 1

The response will include a parsed field showing how your query is being interpreted:

"parsed": {
  "or": [
    {"field": "email", "match_all": "customer@example.com"},
    {"field": "default", "match_all": "phone"}
  ]
}

The empty phone: is being parsed as a search for the literal word “phone” in the default field, not as a phone field search. That’s why you’re getting unexpected customers, it’s matching anyone with “phone” in their searchable data.

Here’s the correct syntax depending on what you’re trying to achieve:

If you want customers with a specific email OR any phone number:

'email:customer@example.com OR phone:*'

If you want customers with a specific email OR a specific phone:

'email:customer@example.com OR phone:"+15551234567"'

If you only want to search by email:

'email:customer@example.com'

The wildcard * in phone:* matches any customer with a phone number, which gives you the proper OR logic you’re looking for. The debugging header is helpful for troubleshooting these kinds of query issues in the future.