content-management-systemstrapinuxt-strapi

Strapi : An error occurred during models config fetch


I was using strap 3.0.0.next-11 and then migrated my APIs to 3.6.8 version.

In 3.6.8 i see this error in a pop-up , for collections which has relations:

An error occurred during models config fetch.

on logs i see this error :

Cast to ObjectId failed for value "http://54.179.156.135:1339/uploads/d26af51633f2451a934896bfc125ec90.jpg" at path "_id" for model "file"

Why is this happening on 3.6.8 ? I have been using the older version without any issues and with this new version I am unable to feth anything.

I am using following : node : 14.17.6 (LTS) npm : 6.14.15 strapi : 3.6.8

I have also attached the image of my package.json.

enter image description here


Solution

  • So I figured out the reason why this was happening in my case. After migrating to 3.6.8 , the fields in model which have type :

    "thumbnail": {
          "model": "file",
          "via": "related",
          "plugin": "upload"
     }
    

    need to have values stored as ObjectId in database as a reference to an entry in upload_file which is maintained by strapi internally.

    earlier, thumbnail would store value as a string url ( url of the image ).

    Example :

    thumbnail : https://my_image_url_path/img.jpg
    

    Now , thumbnail stores the reference i.e. ObjectId , which refers to an entry in the upload_file collection which is responsible for maintaining all the images uploaded via strapi upload api.

    Example :

    thumbnail : ObjectId("60f53bf69f811d268d8fedb1")