throws TypeError if multiple reference field contains validation for non-existent content type
cachrisman opened this issue · 3 comments
Consider the example of a content type which has a multiple reference field and that field has a validation to only accept entries of certain content types with the ids: series
, season
, video
. The model has since changed and series
has been deleted and replaced with show
. The validation on that multiple reference field is now invalid.
When I use this tool in the above mentioned situation I get
(node:31538) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'name' of undefined
(node:31538) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I think this tool could deal with that invalid reference by either labeling it as invalid (with the benefit of alerting the user to this error) or by excluding it quietly.
Happy to provide a PR with a fix.
Thank you for reporting this. I haven't encountered this before, and am wondering now how this could have happened? Can you please provide an example of model to debug?
Is Contentful keeping references to the non-existing model?
Also, PR is more then welcome and appreciated! :)
Thanks!
Here is an example content model:
https://gist.github.com/cachrisman/f641b8988c328582878f56f6138a43a7
or see this image
Now imagine I delete the series
content type and add a new content type called show
which does exactly the same thing as series. Essentially I've renamed series
to show
. Here is an updated content model
https://gist.github.com/cachrisman/0b550dffef61ba5e4fed81d91f5c2626
Hey @cachrisman
terribly sorry for the slightly delayed reply .. I think I've slept for a year :)
Anyways, the issue has been solved in a recent commit eab85ea and a new version was published 1.2.0
Thank you once again for the detailed bug report, attached model helped.
I also added support to run against local file, without even using contentful API.
npx contentful-graph ./your-model.json
which does the same locally.
If this is still relevant, please check, if not, sorry for the delayed response.
Cheers