PrivateMembersData queries fail on some fields with "no value found for <field name>"

I’m trying to query PrivateMembersData to find the member(s) with a given phone number registered. An error is thrown whenever a query that references the “phones” field is executed saying that the field can’t be found.

I got the field key “phones” from both this article and looking at the PrivateMembersData collection in Content Manager.

I’ve verified that I can access some fields with the exact same query, e.g. “language”, but that others also fail, e.g. “emails” and “mainPhone”

My minimal repro:

export async function testFunction() {
    await wixData
    .query("Members/PrivateMembersData")
    .isNotEmpty("language")
    .find({ suppressAuth: true })
    // Succeeds with array of Members

    await wixData
    .query("Members/PrivateMembersData")
    .isNotEmpty("phones")
    .find({ suppressAuth: true })
    // Fails with:
    // Unknown error. Request ID: 1648700692.9992957099208113501. Message: 
    // {
    //     "message": "internal_error, details: {\"error\":\"No value found for 'phones'\"}",
    //     "details": { "category": "internal_error", "error": "No value found for 'phones'" }
    // }
}

This error happens both if I run it as a test function from the Wix editor and when it’s called from my live site

I never really worked with PrivateMembersData,
But a query should return something.
The only thing you now did was searched for something but not returned anything.
So behind .find() add

 .then((result) =>{
console.log(result.items)
})

Hope this works for you.

Kind regards,
Kristof

Hi Kristof, thanks for your reply

I think you’re pointing out that in my example code I don’t do anything with the results in the Promise returned by .find()

That’s true - sorry for the confusion. I wanted to keep my example code as small as possible.

The point is that the Promise returned from .find() rejects with an internal error. From what I can tell, that error claims that the field key “phones” doesn’t exist. I’m pretty sure it should, however.

This fuller example demonstrates more clearly:

export async function testFunction() {
    wixData
        .query("Members/PrivateMembersData")
        .isNotEmpty("phones")
        .find({ suppressAuth: true })
        .then((result) => {
            console.log("Promise resolved")
            console.log(result.items)
        })
        .catch((err) => {
            console.log("Promise rejected")
            console.log(err)
        })
    // See the following in console:
    // > "Promise rejected"
    // > Unknown error. Request ID: 1648731133.87713921536113211880. Message: 
    // {"message":"internal_error, details: {\"error\":\"No value found for 'phones'\"}",
    //  "details":{"category":"internal_error","error":"No value found for 'phones'"}}.
}