-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
bugSomething isn't workingSomething isn't working
Description
🐛 Bug Description
generateCollections
throws an error on arrays of media files.
I have a content type called "Creations" with a 'mediaGallery' field that contains multiple media. When I call generateCollections
and indicate which fields I want to populate, it works properly until I try to populate that field and I get this error:
[InvalidContentEntryDataError] creations → bl3kfrnc4xffigfb72974zsm data does not match collection schema.
mediaGallery**: **mediaGallery: Expected type `"object"`, received `"array"`
Hint:
See https://docs.astro.build/en/guides/content-collections/ for more information on content schemas.
Error reference:
https://docs.astro.build/en/reference/errors/invalid-content-entry-data-error/
Location:
/home/bruno/Desarrollo/direccioncreacion/webrepositorio/node_modules/astro/dist/content/utils.js:157:26
Stack trace:
at getEntryDataAndImages (file:///home/bruno/Desarrollo/direccioncreacion/webrepositorio/node_modules/astro/dist/content/utils.js:157:26)
at async parseData (file:///home/bruno/Desarrollo/direccioncreacion/webrepositorio/node_modules/astro/dist/content/content-layer.js:204:40)
at async Promise.all (index 0)
at async Promise.all (index 0)
at async file:///home/bruno/Desarrollo/direccioncreacion/webrepositorio/node_modules/p-queue/dist/index.js:230:36
🔍 Steps to Reproduce
- Create a content type in strapi with a field with multiple media
- Call
generateCollections
in thecontent.config.ts
file and populate the field with multiple media. - Get the error.
💡 Expected Behavior
I would expect that field to be parsed properly as an array of media files.
💻 Environment
- Astro Version: 5.14.1
- Node Version: 20.13.0
- OS: Linux
📝 Additional Context
This is how I'm generating the collection and it works:
strapiCollections = await generateCollections({
url: import.meta.env.STRAPI_URL,
token: import.meta.env.STRAPI_TOKEN,
},
[
{
name: "creations",
query: {
populate: [
'featuredImage'
]
},
},
]
);
But if I add the mediaGallery
to the populate array it gives the error.
I tried to use the generateStrapiSchema function but I could not understand very well how to use it since it is not documented.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working