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

Bug: tries to find Metadata after remove a component #19535

Open
angel-luis opened this issue Feb 17, 2024 · 8 comments
Open

Bug: tries to find Metadata after remove a component #19535

angel-luis opened this issue Feb 17, 2024 · 8 comments
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:core Source is core/core 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

@angel-luis
Copy link

angel-luis commented Feb 17, 2024

Bug report

Required System information

  • Node.js version: 20.9.0
  • NPM version: 10.4.0
  • Strapi version: 4.20.0
  • Database: PostgreSQL
  • Operating system: Linux
  • Is your project Javascript or Typescript: TypeScript

Describe the bug

I removed a component, because I misspelled a letter. I was still using it inside a collection in Content Manager. Obviously, after delete it, disappeared. But now, I can't modify the entry of the collection, it says:

Error: Metadata for "sections.mycomponent" not found

Additional context

The obvious solutions has been create the misspelled component again, then delete the stucked entry, and then remove the component again.

@Eventyret Eventyret 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:database Source is core/database package status: pending reproduction Waiting for free time to reproduce the issue, or more information source: core:core Source is core/core version: 4 Issue related to v4 labels Mar 14, 2024
@marciusl
Copy link

Happened same too. Using same version, except node v18 and Sqlite, strapi 4.20.5. Initiated new project just few days ago.

Opening DB i can see that misspelled component metadata is in DB so something fails on migrations.

@ttduongtran
Copy link

I got the same problem too. After removing the component, I can't modify the content. As I see, although the component was removed, this name still in content, when we get content, it's try to query name of component and can not find component and raises error.

temp solution:

  • Try to re-create component which has name is equal to removed components and back to content for removing all contents which are including old component. Then, we can remove component.

@bogimobi
Copy link

bogimobi commented Apr 8, 2024

  1. Component A is in dropzone of collection
  2. Collection is created as entity
  3. Move component A to a different category

The component is 'missing' from the entity and throws internal server error if we try to save the entity
Once we return the component to the original category, we can again see the component in the entity with its previously saved data and the save works as expected

@tmxichalakes
Copy link

tmxichalakes commented Apr 18, 2024

I just ran into this issue. Let's say I have two components, Foo and Bar, where Foo is a collection that implements Bar repeatably.

Reproduction steps:

  1. Create an instance of Foo.
  2. Add an instance of Bar to the newly created Foo.
  3. In the Content-Type Builder, delete Bar entirely.
  4. Attempt to save some other field on the instance of Foo.

This fails because in background, Strapi is saving the relationship between the instance of Foo and the instance of Bar in a table called foo_components. Each record in that table has a field called component_type which would then be bar. When I delete the Bar component, while the rest of the schema is updated, records from that particular table are not removed.

I was able to resolve the issue by manually accessing the Postgres database and running the following:

DELETE FROM foo_components WHERE component_type = 'bar'

This only worked because I have direct access to the database, but it is entirely conceivable that I might be in an architecture where I do not have direct access, (e.g. some cloud based db provider). In that case, I don't know what I would do.

Preferably, the process of deleting a component is adjusted to clean up the join table associating such components.

@PierreCavalet
Copy link

This is a big problem when working with git branches because as soon as you checkout a branch where your component does not exists, if you haven't removed it before your checkout, your content is doomed. You can't remove it, you can't fetch it, it is stuck.

@aleksandrjet
Copy link

I made fix #20167, it seems to work

@designtology
Copy link

This bug is still there and it broke my whole cms. I am not able to receive any data for my API anymore. Why is there no possibility to rebuild the database schamas for all components? Even when I add a new component, there is no possibility for me to pull the changes since strapi wont recognize the new components as long as you dont copy your local databse... With all the created content being replaced of course. Is this normal?

@aleksandrjet
Copy link

@designtology try to check your db and remove invalid values, while we wait fix

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:core Source is core/core 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 (Open)
Status: To review
Development

No branches or pull requests

9 participants