Skip to content

Cannot restore backup due to DeserializationError #1788

Closed
@wampiedriessen

Description

@wampiedriessen

Self-Hosted Version

22.10.0

CPU Architecture

x86_64

Docker Version

20.10.21

Docker Compose Version

1.29.2

Steps to Reproduce

  1. On an existing installation, run the command as specified in the docs:
    https://develop.sentry.dev/self-hosted/backup/
    docker-compose run --rm -T -e SENTRY_LOG_LEVEL=CRITICAL web export > sentry/backup.json
  2. On a fresh, new machine. install all prerequisites.
  3. Install sentry using the install.sh script. (install same version of Sentry as on the existing machine)
  4. Copy the export file over from the existing to this new machine
  5. Remove garbage from the top of the backup-file. (something with certs)
  6. Then, run (as per the docs) docker-compose run --rm -T web import /etc/sentry/backup.json

Expected Result

Everything went well, the backup was restored. Now I only need to docker-compose up -d and I'm done.

..except not..

Actual Result

This is the output from the restore command:

Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
14:59:27 [INFO] sentry.plugins.github: apps-not-configured
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/django/core/serializers/python.py", line 143, in Deserializer
    data[field.name] = field.to_python(field_value)
  File "/usr/local/lib/python3.8/site-packages/sentry/db/models/fields/picklefield.py", line 54, in to_python
    return json.loads(value)
  File "/usr/local/lib/python3.8/site-packages/sentry/utils/json.py", line 114, in loads
    return _default_decoder.decode(value)
  File "/usr/local/lib/python3.8/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.8/site-packages/simplejson/decoder.py", line 392, in raw_decode
    raise TypeError("Input string must be text, not bytes")
TypeError: Input string must be text, not bytes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/sentry", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/site-packages/sentry/runner/__init__.py", line 188, in main
    func(**kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/sentry/runner/decorators.py", line 29, in inner
    return ctx.invoke(f, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/sentry/runner/commands/backup.py", line 19, in import_
    for obj in serializers.deserialize("json", src, stream=True, use_natural_keys=True):
  File "/usr/local/lib/python3.8/site-packages/django/core/serializers/json.py", line 69, in Deserializer
    yield from PythonDeserializer(objects, **options)
  File "/usr/local/lib/python3.8/site-packages/django/core/serializers/python.py", line 145, in Deserializer
    raise base.DeserializationError.WithData(e, d['model'], d.get('pk'), field_value)
django.core.serializers.base.DeserializationError: Input string must be text, not bytes: (sentry.option:pk=1) field_value was '1667227606.5980415'

My backup.json indeed contains a property that looks like this:

{
  "model": "sentry.option",
  "pk": 1,
  "fields": {
    "key": "sentry:last_worker_ping",
    "value": 1667227606.5980415,
    "last_updated": "2022-10-31T14:46:46.598Z"
  }
},

And if I change that to:

{
  "model": "sentry.option",
  "pk": 1,
  "fields": {
    "key": "sentry:last_worker_ping",
-   "value": 1667227606.5980415,
+   "value": "1667227606.5980415",
    "last_updated": "2022-10-31T14:46:46.598Z"
  }
},

The import isn't fixed. but it throws another DeserializationError at a later property in the backup file.

{
  "model": "sentry.option",
  "pk": 4,
  "fields": {
    "key": "auth.allow-registration",
    "value": false,
    "last_updated": "2022-02-07T16:29:19.040Z"
  }
},

It seems to only accept String-values in the "value" part.

Event ID

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions