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

import_content: Dry run option with more verbose deserializer validation feedback

Open fredvd opened this issue 3 years ago • 0 comments

While test-using collective.exportimport I'm running into edge cases. I could solve these solve these by adding more code to a subclassed export_content or import_content view in my own custom migrationhelper package.

But the edge case is often 1 field on 1-3 content items in a 8 year old site. It's just not worth it to try to catch these in code, but easier to fix in the source site. See #12 as an example.

The main cause for validation error is the schema validation running at the deserializer step on import_content in plone.restapi. And plone.restapi is catching all validation errors and rethrowing them with a generic ValidationError class that only show the field, but not the error. (https://github.com/plone/plone.restapi/blob/f89276054088340b3ec6775db6280b1dc46f0866/src/plone/restapi/deserializer/dxcontent.py#L55-L60)

To support fixing these blips of migration issues, it would be nice to have a 'dry_run' option in the import_content that tries to create and deserialize a json, catches any validation errors and outputs a report of found original errors coming from https://github.com/plone/plone.restapi/blob/f89276054088340b3ec6775db6280b1dc46f0866/src/plone/restapi/deserializer/dxcontent.py#L45

For this to work we'd need a new feature in plone.restapi to not swallow the ValidationError's as shown above.

fredvd avatar May 06 '21 21:05 fredvd