error handling when snapshot file is inappropriate #21

Open
opened 2024-10-31 14:03:11 +00:00 by pedro · 2 comments
Owner

Related to #13, I tried for several minutes reproduce it without success

But I got one time this error parsing a modified snapshot (seeing how it fails or not)

devicehub-django-1  | + ./manage.py up_snapshots example/snapshots/ user@example.org
devicehub-django-1  | DOMAIN: demo.ereuse.org
devicehub-django-1  | Traceback (most recent call last):
devicehub-django-1  |   File "/opt/devicehub-django/./manage.py", line 22, in <module>
devicehub-django-1  |     main()
devicehub-django-1  |   File "/opt/devicehub-django/./manage.py", line 18, in main
devicehub-django-1  |     execute_from_command_line(sys.argv)
devicehub-django-1  |   File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
devicehub-django-1  |     utility.execute()
devicehub-django-1  |   File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
devicehub-django-1  |     self.fetch_command(subcommand).run_from_argv(self.argv)
devicehub-django-1  |   File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 413, in run_from_argv
devicehub-django-1  |     self.execute(*args, **cmd_options)
devicehub-django-1  |   File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 459, in execute
devicehub-django-1  |     output = self.handle(*args, **options)
devicehub-django-1  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
devicehub-django-1  |   File "/opt/devicehub-django/evidence/management/commands/up_snapshots.py", line 39, in handle
devicehub-django-1  |     self.read_directory(path)
devicehub-django-1  |   File "/opt/devicehub-django/evidence/management/commands/up_snapshots.py", line 47, in read_directory
devicehub-django-1  |     self.open(filepath)
devicehub-django-1  |   File "/opt/devicehub-django/evidence/management/commands/up_snapshots.py", line 51, in open
devicehub-django-1  |     content = json.loads(file.read())
devicehub-django-1  |                          ^^^^^^^^^^^
devicehub-django-1  |   File "<frozen codecs>", line 322, in decode
devicehub-django-1  | UnicodeDecodeError: 'utf-8' codec can't decode byte 0xaa in position 16: invalid start byte
devicehub-django-1 exited with code 1

independently on how to reproduce this, it would be nice to have a error handler here d4f50961bc/evidence/management/commands/up_snapshots.py (L51)

Related to #13, I tried for several minutes reproduce it without success But I got one time this error parsing a modified snapshot (seeing how it fails or not) ``` devicehub-django-1 | + ./manage.py up_snapshots example/snapshots/ user@example.org devicehub-django-1 | DOMAIN: demo.ereuse.org devicehub-django-1 | Traceback (most recent call last): devicehub-django-1 | File "/opt/devicehub-django/./manage.py", line 22, in <module> devicehub-django-1 | main() devicehub-django-1 | File "/opt/devicehub-django/./manage.py", line 18, in main devicehub-django-1 | execute_from_command_line(sys.argv) devicehub-django-1 | File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line devicehub-django-1 | utility.execute() devicehub-django-1 | File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute devicehub-django-1 | self.fetch_command(subcommand).run_from_argv(self.argv) devicehub-django-1 | File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 413, in run_from_argv devicehub-django-1 | self.execute(*args, **cmd_options) devicehub-django-1 | File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 459, in execute devicehub-django-1 | output = self.handle(*args, **options) devicehub-django-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ devicehub-django-1 | File "/opt/devicehub-django/evidence/management/commands/up_snapshots.py", line 39, in handle devicehub-django-1 | self.read_directory(path) devicehub-django-1 | File "/opt/devicehub-django/evidence/management/commands/up_snapshots.py", line 47, in read_directory devicehub-django-1 | self.open(filepath) devicehub-django-1 | File "/opt/devicehub-django/evidence/management/commands/up_snapshots.py", line 51, in open devicehub-django-1 | content = json.loads(file.read()) devicehub-django-1 | ^^^^^^^^^^^ devicehub-django-1 | File "<frozen codecs>", line 322, in decode devicehub-django-1 | UnicodeDecodeError: 'utf-8' codec can't decode byte 0xaa in position 16: invalid start byte devicehub-django-1 exited with code 1 ``` independently on how to reproduce this, it would be nice to have a error handler here https://gitea.pangea.org/ereuse/devicehub-django/src/commit/d4f50961bc6e5137fc513628fd59c7ebd48d3d0b/evidence/management/commands/up_snapshots.py#L51
Owner

Added exception handling on ereuse/devicehub-django#25

Added exception handling on ereuse/devicehub-django#25
Author
Owner

dado que tenemos que hacer merge otra vez de PR 25 pero adaptado a más commits, reabro

dado que tenemos que hacer merge otra vez de PR 25 pero adaptado a más commits, reabro
pedro reopened this issue 2024-11-10 02:32:46 +00:00
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ereuse/devicehub-django#21
No description provided.