Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to publish Collection Type entries with complex schema due to non-existent database column #20284

Open
Duplicated opened this issue May 8, 2024 · 1 comment
Assignees
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:content-manager Source is core/content-manager package source: core:database Source is core/database package status: pending reproduction Waiting for free time to reproduce the issue, or more information version: 4 Issue related to v4

Comments

@Duplicated
Copy link

Required System Information

  • Node.js version: 18.18.2
  • Yarn version: 1.22.19
  • Strapi version: 4.24.2 (tested on 4.16.2 initially, but issue is still reproducible on both versions)
  • Database: postgres
  • Operating system: macOS
  • Is your project Javascript or Typescript: Typescript

Describe the Bug

As a user, I cannot publish any content on this collection type due to Strapi's query engine generating a query that targets a nonexistent column name in table files

Steps to Reproduce

  1. Create a collection type with this schema (omitting components inside dynamic zones here due to complexity):
{
  "kind": "collectionType",
  "collectionName": "my_feeds",
  "info": {
    "singularName": "my-feed",
    "pluralName": "my-feeds",
    "displayName": "My News Feed",
    "description": ""
  },
  "options": {
    "draftAndPublish": true
  },
  "pluginOptions": {
    "i18n": {
      "localized": true
    }
  },
  "attributes": {
    "Feed_Type": {
      "type": "dynamiczone",
      "components": [
        "feed.type-a",
        "feed.type-b",
        "feed.type-c",
        "feed.type-d",
        "feed.type-e"
      ],
      "pluginOptions": {
        "i18n": {
          "localized": true
        }
      }
    },
    "Audience": {
      "type": "component",
      "repeatable": false,
      "component": "utility.audience",
      "pluginOptions": {
        "i18n": {
          "localized": false
        }
      }
    },
    "Tags": {
      "type": "component",
      "repeatable": false,
      "component": "utility.tags",
      "pluginOptions": {
        "i18n": {
          "localized": false
        }
      }
    },
    "Actions": {
      "type": "dynamiczone",
      "components": [
        "shared.action-a",
        "shared.action-b",
        "shared.action-c",
        "shared.action-d",
        "shared.action-e",
        "shared.action-f",
        "shared.action-g",
        "shared.action-h"
      ],
      "pluginOptions": {
        "i18n": {
          "localized": true
        }
      }
    },
    "Button": {
      "type": "dynamiczone",
      "components": [
        "button.goto-a",
        "button.goto-b",
        "button.goto-c",
      ],
      "max": 2,
      "min": 0,
      "required": false,
      "pluginOptions": {
        "i18n": {
          "localized": true
        }
      }
    },
  }
}
  1. Fill out and save the content
  2. Try to publish this same content

Expected Behavior

As a user, I should be able to publish this content

Screenshots

On the admin panel UI, there's only the alert box saying Internal Server Error. But on the API server side, there are more useful information:
Screenshot 2567-05-09 at 02 02 57
And this is the current schema for table files:
Screenshot 2567-05-09 at 02 07 56

Right now, I'm still trying to figure out a workaround for this issue, but it is literally breaking the app on the user's side if they can't publish contents.

Note: I saw that #20188 has encountered a similar issue with countDraftRelations, except that it appears to be due to insufficient permissions. In this case, the generated database query is incorrect in the first place.

@Duplicated
Copy link
Author

Duplicated commented May 9, 2024

Actually, it turns out that I shouldn't have omitted the component structure.

Root cause

Having a media field inside a component that is also a part of a dynamic zone will trigger this specific error:

(root of content type schema)
|
- Dynamic Zone A
        |
    Component A1 
              |--> field A1_a, type: media // this triggers error
              |--> field A1_b, type: richtext

However, using the field in a standalone component, or even using the field directly, does not trigger said error:

// This works
(root of content type schema)
|
- Component A2 
            |--> field A2_a, type: media // no error
            |--> field A2_b, type: boolean
            |--> field A2_c, type: string
// This also works
(root of content type schema)
|
|--> field B_1, type: media // no error
|--> field B_2, type: string

@joshuaellis joshuaellis added issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:content-manager Source is core/content-manager package source: core:database Source is core/database package status: pending reproduction Waiting for free time to reproduce the issue, or more information version: 4 Issue related to v4 labels May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:content-manager Source is core/content-manager package source: core:database Source is core/database package status: pending reproduction Waiting for free time to reproduce the issue, or more information version: 4 Issue related to v4
Projects
Status: To be reviewed
Status: To be reviewed (Open)
Status: To review
Development

No branches or pull requests

3 participants