strapi / strapi

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

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

Open laurenskling opened 2 months ago

laurenskling commented 2 months 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 2 months 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 2 months ago

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

laurenskling commented 2 months 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 2 months ago

Thank you 🙏

laurenskling commented 2 months 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 2 months 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 months ago

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

laurenskling commented 2 weeks ago

@Marc-Roig this is still happening to me on 5.3.0, is it not included in the release?

Marc-Roig commented 2 weeks ago

it should be included in 5.3.0 🤔 is it the same exact issue? you see that error when having a filters attribute in your schema?

laurenskling commented 2 weeks ago

Jep. 5.3.0:

Request URL:
http://0.0.0.0:1337/content-manager/collection-types/plugin::vehicles.vdp/q7v8ji0n0zklg2xbe31dslfr/actions/countDraftRelations?
Request Method:
GET
Status Code:
400 Bad Request
{
    "data": null,
    "error": {
        "status": 400,
        "name": "ValidationError",
        "message": "Invalid key publishedAt at searchResultsPage.filters",
        "details": {
            "key": "publishedAt",
            "path": "searchResultsPage.filters"
        }
    }
}
Marc-Roig commented 1 day ago

We are working on this internally! we aim to fix this by this week