bitsy-ai / printnanny-os

Image repository, change logs, and issue tracking for PrintNanny OS
GNU Affero General Public License v3.0
23 stars 2 forks source link

Submitting a crash report with --id returns 500 error #202

Closed leigh-johnson closed 1 year ago

leigh-johnson commented 1 year ago

Describe the bug

When you run printnanny crash-report --id=<uuid> via command-line, a zip of system logs should be uploaded to existing crash report by uuid.

Instead, this command is returning error:

"Field 'id' expected a number but got <django.contrib.auth.models.AnonymousUser object"

Issue.txt

-----------------------
Build Info:  |
-----------------------
IMAGE_NAME = printnanny-release-image-raspberrypi4-64-20230111183507
DISTRO_PRETTY = PrintNanny Linux 0.5.2 (Emerald)
VARIANT_NAME = PrintNanny OS Core
VARIANT_ID = core
DISTRO = printnanny
DISTRO_NAME = PrintNanny Linux
DISTRO_VERSION = 0.5.2
DISTRO_CODENAME = Emerald
ID_LIKE = BitsyLinux
HOME_URL = https://printnanny.ai
BUG_REPORT_URL = https://github.com/bitsy-ai/printnanny-os/issues
YOCTO_VERSION = 4.0.2
YOCTO_CODENAME = Langdale
MACHINE = raspberrypi4-64
TUNE_PKGARCH = cortexa72
-----------------------
Layer Revisions:      |
-----------------------
meta              = langdale:a3e3b740e140d036122f7b11e2ac452bda548444
meta-poky         = langdale:a3e3b740e140d036122f7b11e2ac452bda548444
meta-yocto-bsp    = langdale:a3e3b740e140d036122f7b11e2ac452bda548444
meta-raspberrypi  = libcamera-v0.0.3:104a8b9290ab4da92c8f693e2fdc42a6396975d2
meta-oe           = langdale:c5668905a6d8a78fb72c2cbf8b20e91e686ceb86
meta-python       = langdale:c5668905a6d8a78fb72c2cbf8b20e91e686ceb86
meta-multimedia   = langdale:c5668905a6d8a78fb72c2cbf8b20e91e686ceb86
meta-bitsy        = main:b3bc49777261b11e844fde1edb755920547361e2
meta-neural-network = master:fed68f0a659c9b6431985c156141dc28dc4c2275
meta-printnanny   = main:b3bc49777261b11e844fde1edb755920547361e2
meta-networking   = langdale:c5668905a6d8a78fb72c2cbf8b20e91e686ceb86
meta-filesystems  = langdale:c5668905a6d8a78fb72c2cbf8b20e91e686ceb86
meta-initramfs    = langdale:c5668905a6d8a78fb72c2cbf8b20e91e686ceb86
meta-webserver    = langdale:c5668905a6d8a78fb72c2cbf8b20e91e686ceb86
meta-swupdate     = master:5e611f44db1b9333342ed61d77a3c3ed7be69c2b
workspace         = langdale:a3e3b740e140d036122f7b11e2ac452bda548444
meta-microcontroller = master:9f396e595b2d639be7f2b494f4a61e48d9495058
leigh-johnson commented 1 year ago

Re-opening as a regression. We're seeing this error in the current webapp build:

2023-01-26 15:19:44.742 PST
ERROR 2023-01-26 23:19:44,742 exceptions 16 139860798482176 FATAL API ERROR uuid=4114f6b5629741f49ef1310ae67accb4 exc=Field 'id' expected a number but got <django.contrib.auth.models.AnonymousUser object at 0x7f33bfde0e50>. traceback=Traceback (most recent call last):
2023-01-26 15:19:44.742 PST
File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 1823, in get_prep_value
2023-01-26 15:19:44.742 PST
return int(value)
2023-01-26 15:19:44.742 PST
File "/usr/local/lib/python3.9/site-packages/django/contrib/auth/models.py", line 420, in __int__
2023-01-26 15:19:44.742 PST
raise TypeError('Cannot cast AnonymousUser to int. Are you trying to use it in place of User?')
2023-01-26 15:19:44.742 PST
TypeError: Cannot cast AnonymousUser to int. Are you trying to use it in place of User?
2023-01-26 15:19:44.742 PST
The above exception was the direct cause of the following exception:
2023-01-26 15:19:44.742 PST
{}
2023-01-26 15:19:44.742 PST
Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch response = handler(request, *args, **kwargs) File "/usr/local/lib/python3.9/site-packages/drf_spectacular/drainage.py", line 159, in wrapped_method return method(self, request, *args, **kwargs) File "/usr/local/lib/python3.9/site-packages/rest_framework/mixins.py", line 82, in partial_update return self.update(request, *args, **kwargs) File "/usr/local/lib/python3.9/site-packages/drf_spectacular/drainage.py", line 159, in wrapped_method return method(self, request, *args, **kwargs) File "/usr/local/lib/python3.9/site-packages/rest_framework/mixins.py", line 65, in update instance = self.get_object() File "/usr/local/lib/python3.9/site-packages/rest_framework/generics.py", line 83, in get_object queryset = self.filter_queryset(self.get_queryset()) File "/usr/local/lib/python3.9/site-packages/rest_framework/generics.py", line 150, in filter_queryset queryset = backend().filter_queryset(self.request, queryset, self) File "/app/./print_nanny_webapp/utils/api/filters.py", line 8, in filter_queryset return queryset.filter(user=request.user) File "/usr/local/lib/python3.9/site-packages/safedelete/queryset.py", line 72, in filter return super(SafeDeleteQueryset, queryset).filter(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 941, in filter return self._filter_or_exclude(False, args, kwargs) File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 961, in _filter_or_exclude clone._filter_or_exclude_inplace(negate, args, kwargs) File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 968, in _filter_or_exclude_inplace self._query.add_q(Q(*args, **kwargs)) File "/usr/local/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1416, in add_q clause, _ = self._add_q(q_object, self.used_aliases) File "/usr/local/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1435, in _add_q child_clause, needed_inner = self.build_filter( File "/usr/local/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1370, in build_filter condition = self.build_lookup(lookups, col, value) File "/usr/local/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1216, in build_lookup lookup = lookup_class(lhs, rhs) File "/usr/local/lib/python3.9/site-packages/django/db/models/lookups.py", line 25, in __init__ self.rhs = self.get_prep_lookup() File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related_lookups.py", line 117, in get_prep_lookup self.rhs = target_field.get_prep_value(self.rhs) File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 1825, in get_prep_value raise e.__class__( TypeError: Field 'id' expected a number but got <django.contrib.auth.models.AnonymousUser object at 0x7f33bfde0e50>.
2023-01-26 15:19:44.743 PST
context={'view': <print_nanny_webapp.crash_reports.api.views.CrashReportViewSet object at 0x7f33bfde0520>, 'args': (), 'kwargs': {'id': '40499ccf-da7b-4723-bd32-ab12659cf84e'}, 'request': <rest_framework.request.Request: PATCH '/api/crash-reports/40499ccf-da7b-4723-bd32-ab12659cf84e/'>}
2023-01-26 15:19:44.759 PST
ERROR 2023-01-26 23:19:44,743 log 16 139860694259456 Internal Server Error: /api/crash-reports/40499ccf-da7b-4723-bd32-ab12659cf84e/
leigh-johnson commented 1 year ago

:+1: Verified this is fixed by submitting an anonymous crash report, then appending to submitted report by id.