[v4] strapi populate query error "entry must be an object"

System Information
  • Strapi Version: 4.0.0
  • Operating System: Windows 10
  • Database: sqlite
  • Node Version:
  • NPM Version:
  • Yarn Version: 1.22.15

i have table with relation one to many for example an article have many comment.
i want populate all article with commants
in my find function on service articles query like this.

let result = await strapi.entityService.findMany('api::article.article', {
      populate: {
        comment_id: {
          fields: [
            "id",
            "comment",
            "status"
          ],
          filters: {
            status: {
              $eq: eduStatus.ACTIVE
            }
          }
        }
      },
    });

and when i run from postman, it return

{
    "data": null,
    "error": {
        "status": 500,
        "name": "InternalServerError",
        "message": "Internal Server Error"
    }
}

and in terminal error “entry must be an object”

how to fixed this?

1 Like

Commenting out line 52 throw new Error(‘Entry must be an object’); in node_modules/@strapi/strapi/lib/core-api/controller/transform.js in Strapi 4.1.7 fixed the issue. I am working on to know the cause of the issue, will post here if it’s resolved.

Looking at the docs Populating for Query Engine API - Strapi Developer Docs

It seems like you should be able to do

let result = await strapi.entityService.findMany('api::article.article', {
      populate: {
        comment_id: {
          select: [
            "id",
            "comment",
            "status"
          ],
          where: {
            status: {
              $eq: eduStatus.ACTIVE
            }
          }
        }
      },
    });

Same issue for me. Are you able to solve this?

I had some messed up relational field. Error went away after i remade the relation.

1 Like

Care to explain what you mean by “messed up”? I have the same problem but no clue to where to look at.

same problem for me .please explain the solution

Are you on the newest strapi version?

yes. strapiv 4.7.1

same here. 4.7.1

I would recommand opening an issue on github for this

Same issue. I found that this issue connected with relations but i have plenty of relations. I couldn’t find which relation reason for the error. if anyone find solution it

Yes, your solution worked for me