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

_pickle.UnpicklingError after failed migration #585

Closed
Adam01 opened this issue Sep 13, 2024 · 0 comments · Fixed by #588
Closed

_pickle.UnpicklingError after failed migration #585

Adam01 opened this issue Sep 13, 2024 · 0 comments · Fixed by #588

Comments

@Adam01
Copy link

Adam01 commented Sep 13, 2024

Describe the problem

Migrations containing 0003_drop_pickle often fail. I recently noticed this happens when 0003 succeeds in a migration where another migration has failed, and running the migration again after fixing the other migration leads to this error.

Steps to reproduce

Migrate to 0003_drop_pickle after a previous call to migrate failed where 0003 succeeded in that migration.

System configuration

  • Django version: 5.1.1
  • Python version: 3.12
  • Django-Constance version: 4.1.1

Last line of stack trace

  File "/app/.heroku/python/lib/python3.12/site-packages/django/db/migrations/migration.py", line 132, in apply
    operation.database_forwards(
  File "/app/.heroku/python/lib/python3.12/site-packages/django/db/migrations/operations/special.py", line 196, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/app/.heroku/python/lib/python3.12/site-packages/constance/migrations/0003_drop_pickle.py", line 23, in migrate_pickled_data
    constance.value = dumps(pickle.loads(b64decode(constance.value.encode())))  # noqa: S301
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_pickle.UnpicklingError: invalid load key, '\xb7'.
Django migrations failed

Constance table 'value' column values

  1. {"type": "default", "value": ""}
  2. gAJHP564UeuFHrgu

Workaround

Delete records with 'value' column containing JSON

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

Successfully merging a pull request may close this issue.

1 participant