djangocms-transfer icon indicating copy to clipboard operation
djangocms-transfer copied to clipboard

Import Error: File is not valid

Open sharkovsky opened this issue 5 years ago • 2 comments

Hello,

I am getting a File is not valid error when I try to import some plugins.

By inspecting with a debugger, I have pinned down the issue to the presence of the plugin_type field within the data dictionary of a plugin. To be more clear, here is a json example of a problematic plugin:

[{
    "pk": 155,
    "creation_date": "2020-11-03T17:29:48.460Z",
    "position": 0,
    "plugin_type": "BannerTopPlugin",
    "parent_id": null,
    "data": {
        "path": "002J",
        "depth": 1,
        "numchild": 0,
        "placeholder": 13,
        "parent": null,
        "position": 0,
        "language": "it",
        "plugin_type": "BannerTopPlugin",
        "creation_date": "2020-11-03T17:29:48.460Z",
        "changed_date": "2020-11-03T17:29:48.463Z"
}}]

The existence of the plugin_type field within the data dictionary confuses the _object_version_data_hook function, which tries to instantiate an ArchivedPlugin, but fails because of the existence of unknown parameters such as path. Indeed, I could implement a simple fix by patching the _object_version_data_hook to return right away the data dictionary untouched if it doesn't contain the pk key.

Obviously this fix is not sustainable, and it would be better to understand why the plugin_type key is duplicated in the first place. An important hint that I discovered is that this problem seems to only happen with plugins that don't have an associated model in the database.

I am using Django 2.2, django-cms 3.7.4 and djangocms-transfer 1.0.0

Thank you!

sharkovsky avatar Jan 22 '21 16:01 sharkovsky

I faced a similar problem and doing the folliwing manually does solve the error

Remove plugin_type from data

srinathganesh avatar Nov 16 '21 04:11 srinathganesh

I met the same problem

GinnWG avatar Feb 17 '22 08:02 GinnWG