Getting an error ERROR: could not validate document '%!s(<nil>)' for read

Hi, I’m getting the above error when calling a graphql customer resolver endpoint. It works fine when I’m calling the function in the mongodb cloud Function Editor or GraphQL. But when I call it from the C# GraphQL.Client.Http library it shows that error in my mongo logs.

I’ve seen this error before but usually it has an id to see which doc is not conforming to the schema. I ran Run Validation in the schema tab on all my tables and nothing showed up.


Found the issue

I was doing this to find the max value

let maxDhvResult = await collection.aggregate([{ $group : { _id: null, maxDataHubVersion: { $max : "$dataHubVersion" }}}]).toArray();

And it’s weird that it works with mongo cloud function editor/graphql but not when I call the graphql customresolver from a C# client.

Changing it to below fixed my issue

let maxDhvResult = await (collection.find({},{dataHubVersion: 1}).sort({datahubVersion:-1}).limit(1).toArray());

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.