You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ValueError when CRUD event involves AnonymousUser: Field 'id' expected a number but got ''
Describe the bug
A ValueError occurs when a CRUD event is performed by an AnonymousUser. Instead of returning None for the user field, an empty string ('') is being passed.
Error Details
*** ValueError: Field 'id' expected a number but got ''.
Traceback (most recent call last):
File "/app/.venv/lib/python3.11/site-packages/django/db/models/fields/related_descriptors.py", line 218, in __get__
rel_obj = self.field.get_cached_value(instance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/django/db/models/fields/mixins.py", line 15, in get_cached_value
return instance._state.fields_cache[cache_name]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'user'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/.venv/lib/python3.11/site-packages/django/db/models/fields/__init__.py", line 2053, in get_prep_value
return int(value)
^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
Cause
The user field is a nullable primary key field that expects either an integer or None. When the user is anonymous, the field should be set to None, but it is receiving an empty string instead.
Expected behavior
The user field should return None for an AnonymousUser, not an empty string.
The text was updated successfully, but these errors were encountered:
ValueError when CRUD event involves AnonymousUser: Field 'id' expected a number but got ''
Describe the bug
A
ValueError
occurs when a CRUD event is performed by anAnonymousUser
. Instead of returningNone
for theuser
field, an empty string (''
) is being passed.Error Details
Cause
The
user
field is a nullable primary key field that expects either an integer orNone
. When the user is anonymous, the field should be set toNone
, but it is receiving an empty string instead.Expected behavior
The
user
field should returnNone
for anAnonymousUser
, not an empty string.The text was updated successfully, but these errors were encountered: