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

EntityHydrator crashes if a parent relation is null #2682

Closed
jnugh opened this issue Feb 20, 2024 · 0 comments · Fixed by #2683
Closed

EntityHydrator crashes if a parent relation is null #2682

jnugh opened this issue Feb 20, 2024 · 0 comments · Fixed by #2683
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@jnugh
Copy link
Contributor

jnugh commented Feb 20, 2024

Describe the bug
Let's say we have three entities (ProductVariant, MetaEntity, Configuration). MetaEntity is a nullable customField of ProductVariant and Configuration is related to MetaEntity.

If I use the EntityHydrator to fetch Configuration I get an error in getRelationEntityAtPath at

const target = parent[part];

because ProductVariant.customFields.metaEntity was null parent['configuration'] is not accessible.
If I understand correctly it would be okay to just return null here as nothing needs to be translated or calculated.

To Reproduce
Define a nullable custom field relation which contains another relation. Hydrate the nested relation while the first one is null.

Expected behavior
It should return null for the top level relation.

Environment (please complete the following information):

  • @vendure/core version: latest (master)
  • Nodejs version: 20
  • Database (mysql/postgres etc): postgres / sqlite

Additional context
I already implemented a fix for this, will create a PR as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants