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

fix: checking for relation type existence #20167

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

aleksandrjet
Copy link

What does it do?

I fixed an error, which happened when deleting content-type or collection in usage. Users faced error here - #19535

Code had error, because checking of existing metadata db.metadata.get(type) finishes with error, if metadata is not exist:

// packages/core/database/src/query/helpers/populate/apply.ts
if (!db.metadata.get(type)) {
    map[type] = {}; // this condition will never be done
    return;
}

// packages/core/database/src/metadata/metadata.ts
export class Metadata extends Map<string, Meta> {
  get(key: string): Meta {
    if (!super.has(key)) {
      throw new Error(`Metadata for "${key}" not found`);
    }

    return super.get(key) as Meta;
  }
}

Why is it needed?

Error happens when deleting component or collection in usage

How to test it?

I didn't add additional tests, current tests are passed

Related issue(s)/PR(s)

I faced this problem too - #19535

@strapi-cla
Copy link

strapi-cla commented Apr 22, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

vercel bot commented Apr 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
contributor-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 22, 2024 5:04am

@aleksandrjet
Copy link
Author

should I do something else to someone checks it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: To be reviewed (Open)
Development

Successfully merging this pull request may close these issues.

None yet

3 participants