Product multi condition query bug

There was a strange situation with the product’s multi condition query,
I found a different situation than expected when using collective_id and product_date to query products. The following is the query statement:

query products($first:Int,$queryStr: String ,$after: String,$last:Int,$before:String){
  products(first: $first,reverse: true, sortKey: UPDATED_AT, query: $queryStr, after: $after,last:$last, before:$before) {
    edges {
      node {
        id
        title
        productType
        vendor
        tags
      }
    }
    pageInfo{
        endCursor
        hasNextPage
        hasPreviousPage
        startCursor
    }
  }
}

I will list the query criteria in three situations:

1.When the condition is only collection-id, the query result is as follows:

variables: {"first":10,"queryStr":"collection_id:\"512040468785\" "}
result: {
    "data": {
        "products": {
            "edges": [
                {
                    "node": {
                        "id": "gid://shopify/Product/10255024587057",
                        "title": "Continuous Setting Mist",
                        "collections": {
                            "edges": [
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/494944092465",
                                        "title": "Automated Collection"
                                    }
                                },
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/512040468785",
                                        "title": "10 and under"
                                    }
                                },
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/512042828081",
                                        "title": "15 and under"
                                    }
                                }
                            ]
                        },
                        "productType": "",
                        "vendor": "Morphe",
                        "tags": []
                    }
                }
            ],
            "pageInfo": {
                "endCursor": "eyJsYXN0X2lkIjoxMDI1NTAyNDU4NzA1NywibGFzdF92YWx1ZSI6IjIwMjUtMDYtMTIgMDE6NTg6MjUuMDAwMDAwIn0=",
                "hasNextPage": false,
                "hasPreviousPage": false,
                "startCursor": "eyJsYXN0X2lkIjoxMDI1NTAyNDU4NzA1NywibGFzdF92YWx1ZSI6IjIwMjUtMDYtMTIgMDE6NTg6MjUuMDAwMDAwIn0="
            }
        }
    }
}

2.When the condition is only productotype, the query result is as follows:

variables: {"first":10,"queryStr":"product_type:\"type0805\""}

result: {
    "data": {
        "products": {
            "edges": [
                {
                    "node": {
                        "id": "gid://shopify/Product/10307753574705",
                        "title": "Test product10 6",
                        "collections": {
                            "edges": [
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/494944092465",
                                        "title": "Automated Collection"
                                    }
                                },
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/494945108273",
                                        "title": "T-RELIEF"
                                    }
                                },
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/494945206577",
                                        "title": "PAIN"
                                    }
                                }
                            ]
                        },
                        "productType": "type0805",
                        "vendor": "devstore-china",
                        "tags": [
                            "0827",
                            "ddd",
                            "test0805"
                        ]
                    }
                },
                {
                    "node": {
                        "id": "gid://shopify/Product/10380646154545",
                        "title": "icy sea (Copy) (Copy)",
                        "collections": {
                            "edges": []
                        },
                        "productType": "type0805",
                        "vendor": "vendor0805",
                        "tags": [
                            "test0805"
                        ]
                    }
                },
                {
                    "node": {
                        "id": "gid://shopify/Product/10380635242801",
                        "title": "icy sea (Copy)",
                        "collections": {
                            "edges": []
                        },
                        "productType": "type0805",
                        "vendor": "vendor0805",
                        "tags": [
                            "test0805"
                        ]
                    }
                },
                {
                    "node": {
                        "id": "gid://shopify/Product/10297947947313",
                        "title": "twilight rain - 6",
                        "collections": {
                            "edges": []
                        },
                        "productType": "type0805",
                        "vendor": "devstore-china",
                        "tags": [
                            "ddd",
                            "Winter"
                        ]
                    }
                },
                {
                    "node": {
                        "id": "gid://shopify/Product/10297947717937",
                        "title": "icy sea",
                        "collections": {
                            "edges": []
                        },
                        "productType": "type0805",
                        "vendor": "vendor0805",
                        "tags": [
                            "test0805"
                        ]
                    }
                }
            ],
            "pageInfo": {
                "endCursor": "eyJsYXN0X2lkIjoxMDI5Nzk0NzcxNzkzNywibGFzdF92YWx1ZSI6IjIwMjUtMDgtMDUgMTc6NTM6NDkuMDAwMDAwIn0=",
                "hasNextPage": false,
                "hasPreviousPage": false,
                "startCursor": "eyJsYXN0X2lkIjoxMDMwNzc1MzU3NDcwNSwibGFzdF92YWx1ZSI6IjIwMjUtMDgtMjcgMTc6NTc6MjUuMDAwMDAwIn0="
            }
        }
    }
}

3.When two conditions are combined, an unexpected situation occurs:

variables: {"first":10,"queryStr":"collection_id:\"512040468785\" OR product_type:\"type0805\""}

result: {
    "data": {
        "products": {
            "edges": [
                {
                    "node": {
                        "id": "gid://shopify/Product/10307753574705",
                        "title": "Test product10 6",
                        "collections": {
                            "edges": [
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/494944092465",
                                        "title": "Automated Collection"
                                    }
                                },
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/494945108273",
                                        "title": "T-RELIEF"
                                    }
                                },
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/494945206577",
                                        "title": "PAIN"
                                    }
                                }
                            ]
                        },
                        "productType": "type0805",
                        "vendor": "devstore-china",
                        "tags": [
                            "0827",
                            "ddd",
                            "test0805"
                        ]
                    }
                },
                {
                    "node": {
                        "id": "gid://shopify/Product/10307753574705",
                        "title": "Test product10 6",
                        "collections": {
                            "edges": [
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/494944092465",
                                        "title": "Automated Collection"
                                    }
                                },
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/494945108273",
                                        "title": "T-RELIEF"
                                    }
                                },
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/494945206577",
                                        "title": "PAIN"
                                    }
                                }
                            ]
                        },
                        "productType": "type0805",
                        "vendor": "devstore-china",
                        "tags": [
                            "0827",
                            "ddd",
                            "test0805"
                        ]
                    }
                },
                {
                    "node": {
                        "id": "gid://shopify/Product/10307753574705",
                        "title": "Test product10 6",
                        "collections": {
                            "edges": [
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/494944092465",
                                        "title": "Automated Collection"
                                    }
                                },
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/494945108273",
                                        "title": "T-RELIEF"
                                    }
                                },
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/494945206577",
                                        "title": "PAIN"
                                    }
                                }
                            ]
                        },
                        "productType": "type0805",
                        "vendor": "devstore-china",
                        "tags": [
                            "0827",
                            "ddd",
                            "test0805"
                        ]
                    }
                },
                {
                    "node": {
                        "id": "gid://shopify/Product/10255024587057",
                        "title": "Continuous Setting Mist",
                        "collections": {
                            "edges": [
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/494944092465",
                                        "title": "Automated Collection"
                                    }
                                },
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/512040468785",
                                        "title": "10 and under"
                                    }
                                },
                                {
                                    "node": {
                                        "id": "gid://shopify/Collection/512042828081",
                                        "title": "15 and under"
                                    }
                                }
                            ]
                        },
                        "productType": "",
                        "vendor": "Morphe",
                        "tags": []
                    }
                }
            ],
            "pageInfo": {
                "endCursor": "eyJsYXN0X2lkIjoxMDI1NTAyNDU4NzA1NywibGFzdF92YWx1ZSI6IjIwMjUtMDYtMTIgMDE6NTg6MjUuMDAwMDAwIn0=",
                "hasNextPage": false,
                "hasPreviousPage": false,
                "startCursor": "eyJsYXN0X2lkIjoxMDMwNzc1MzU3NDcwNSwibGFzdF92YWx1ZSI6IjIwMjUtMDgtMjcgMTc6NTc6MjUuMDAwMDAwIn0="
            }
        }
    }
}

It can be seen that duplicate data appears in the third query result, with ‘Test product10 6’ appearing three times. I am not sure what caused this, can anyone answer this question?

Hey @kyle_liu - I just did a bit of testing on my end here and this does seem like potentially unexpected behaviour. Would you be able to run another test for your last example where the query results show duplicated data, and if possible share an x-request-ID from the API Response headers we send out with our API responses?

I can take a look at our logs here to investigate further and see if I’m able to replicate the behaviour/narrow down what could be causing this. Hope to hear from you soon!

Hi @Alan_G

Of course. This is request id: f04420ac-cc65-4ff0-b937-9de01d50ee0b-1756774546

Thanks @kyle_liu , I was able to pull some logs on my end here, and I believe I’ve replicated what you’re seeing. I’ll get in touch with some folks internally and then loop back with you once I have next steps :slight_smile:

Hey again @kyle_liu, we’re looking into this as a possible bug on our end. I’ll keep you updated with any news/get in touch here when I can confirm a fix. Can’t guarantee an exact turnaround time at the moment, but just wanted to touch base with you to let you know we are investigating this :slight_smile:

Okay, thank you. I hope it can be resolved as soon as possible