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

Import Error: File is not valid #16

Open
sharkovsky opened this issue Jan 22, 2021 · 2 comments
Open

Import Error: File is not valid #16

sharkovsky opened this issue Jan 22, 2021 · 2 comments

Comments

@sharkovsky
Copy link

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!

@srinathganesh
Copy link

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

Remove plugin_type from data

@GinnWG
Copy link

GinnWG commented Feb 17, 2022

I met the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants