strapi / strapi

🚀 Strapi is the leading open-source headless CMS. It’s 100% JavaScript/TypeScript, fully customizable, and developer-first.
https://strapi.io
Other
63.36k stars 8.03k forks source link

countDraftRelations crashes 400 when containing relations to non-DP types #21338

Open laurenskling opened 4 weeks ago

laurenskling commented 4 weeks ago

Bug report

Required System information

Describe the bug

When going to a entry which has relations to content types without draftAndPublish, the countDraftRelations API call crashes and throws errors.

Steps to reproduce the behavior

  1. create a type with a relation to a non-DP type (in my screenshots, searchResultsPage is a relation to a non-DP type)
  2. create and save, or open an existing entry
  3. See error

Expected behavior

no error.

Screenshots

Scherm­afbeelding 2024-09-18 om 19 24 13 Scherm­afbeelding 2024-09-18 om 19 24 24 Scherm­afbeelding 2024-09-18 om 19 24 35
laurenskling commented 4 weeks ago

If you want to see it in action:

https://github.com/strapi/strapi/issues/21354 https://discord.com/channels/811989166782021633/1095091586452426824/1286021240842223678

alexandrebodin commented 3 weeks ago

Hey @laurenskling I think we fixed that before stable. Do you confirm ?

laurenskling commented 3 weeks ago

@alexandrebodin this happened to me when I installed 5.0.0 on my actual codebase. Even with clean DB. Will try to make a good reproduction a.s.a.p., because it does not seem to happen on my clean installed example project. It also doesn't happen on all relation. Will need to look into it why it happens on my searchResultsPage...

alexandrebodin commented 3 weeks ago

Thank you 🙏

laurenskling commented 3 weeks ago

@alexandrebodin Step closer! Just realized, these content types doing this have a (component) field called filters!

If I rename them, the error is gone. Is filters a key we should not use? I think it's conflicting in the code of countDraftRelations on actual document filters.

alexandrebodin commented 3 weeks ago

Wow nice find. it will help see if we can fix the code or if we need to prevent the use of this name 🙏 You rock!

Marc-Roig commented 2 weeks ago

We are working on a fix, filters should be a valid attribute name 😃