collective.exportimport icon indicating copy to clipboard operation
collective.exportimport copied to clipboard

Content importer does not deal correctly with unresolvable references and omits further (necessary processing steps)

Open zopyx opened this issue 3 years ago • 2 comments

We have content-types that contains a RelationChoice field with a value like

related_url': '/community/meinung/onlineangebote-lehramtsstudium'

The referenced object has not been imported yet. So this reference is not resolvable. For this reason, the deserializer throws an error

> /Users/ajung/src/plone6.buildout/src/collective.exportimport/src/collective/exportimport/import_content.py(366)import_new_content()
-> new = deserializer(validate_all=False, data=item)
(Pdb) 
zExceptions.BadRequest: [{'message': 'Could not resolve object for path=/community/meinung/onlineangebote-lehramtsstudium', 'field': 'related_url', 'error': 'ValidationError'}]

and stops with the further processing on the object. E.g. the review state of this object is then not correctly set (and remains in private rather than published state).

zopyx avatar Jun 16 '22 08:06 zopyx

Removing continue in https://github.com/collective/collective.exportimport/blob/main/src/collective/exportimport/import_content.py#L368 resolves the problem for us...perhaps it is the solution since the import of relations is usually done at the end of a migration import.

zopyx avatar Jun 16 '22 08:06 zopyx

Alternatively, the deserializer check could be made optional (through a parameter or environment variable).

zopyx avatar Jun 16 '22 08:06 zopyx