Skip to content

Commit

Permalink
fix: Fixed _pickle.UnpicklingError (#576)
Browse files Browse the repository at this point in the history
The error indicates an issue with unpickling data during the migration process. Specifically, it raises an `_pickle.UnpicklingError` with the message "invalid load key, '{'." The data being loaded may be corrupted or not in the expected format.
  • Loading branch information
felipe3dfx authored Aug 31, 2024
1 parent c690d5e commit cf838ab
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion constance/migrations/0003_drop_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def migrate_pickled_data(apps, schema_editor) -> None: # pragma: no cover
prefixed_key = f'{_prefix}{key}'
value = _rd.get(prefixed_key)
if value is not None:
redis_migrated_data[prefixed_key] = dumps(pickle.loads(value)) # noqa: S301
try:
redis_migrated_data[prefixed_key] = dumps(pickle.loads(value)) # noqa: S301
except pickle.UnpicklingError:
continue
for prefixed_key, value in redis_migrated_data.items():
_rd.set(prefixed_key, value)

Expand Down

0 comments on commit cf838ab

Please sign in to comment.