Skip to content

Commit

Permalink
More safe suppress of pickle-to-json data migration
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-klass committed Sep 3, 2024
1 parent 5ce88b7 commit 081ccbf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions constance/migrations/0003_drop_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ def migrate_pickled_data(apps, schema_editor) -> None: # pragma: no cover
if value is not None:
try:
redis_migrated_data[prefixed_key] = dumps(pickle.loads(value)) # noqa: S301
except pickle.UnpicklingError:
continue
except pickle.UnpicklingError as e:
if value.startswith(b'{"__'):
# Seems like we're facing already migrated data
# Might be related to defaults and when config was accessed while django inits for migration
continue
else:
raise e
for prefixed_key, value in redis_migrated_data.items():
_rd.set(prefixed_key, value)

Expand Down

0 comments on commit 081ccbf

Please sign in to comment.