fix: Fixed _pickle.UnpicklingError (#576)

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.
This commit is contained in:
Felipe Gonzalez 2024-08-31 09:31:21 -05:00 committed by GitHub
parent c690d5ef0f
commit cf838ab28a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)