Skip to content

Cannot restore backup due to DeserializationError #1788

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

Closed
wampiedriessen opened this issue Oct 31, 2022 · 2 comments
Closed

Cannot restore backup due to DeserializationError #1788

wampiedriessen opened this issue Oct 31, 2022 · 2 comments

Comments

@wampiedriessen
Copy link

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

@DAcodedBEAT
Copy link

FYI related discussions are happening in getsentry/sentry#36868

@hubertdeng123
Copy link
Member

I've pinged the team involved, will follow along in that ticket instead of here

@github-actions github-actions bot locked and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants