Repository navigation
Description
Please verify that this bug has NOT been raised before.
- I checked and didn't find a similar issue
Describe the bug*
Hello,
This follows on from issue #12131 that I logged a while back.
PR #12162 seems to have solved the issues within the NotificationMessage class, and my notifications are now being delivered. However, this has revealed a similar issue within the NotificationEntry class.
NotificationEntry.uid is currently defined as an IntegerField, but trigger_notification() passes the object's pk to this field by default. In my case, with the MachineConfig model using a UUID as its primary key, this results in an integer out of range error when the notification is recorded.
I've included the full stack trace below from when a notification is sent.
Thanks,
James.
Steps to Reproduce
Call trigger_notification where obj is passed a MachineConfig instance.
Expected behaviour
The MessageEntry is logged successfully upon the notifications being generated.
Deployment Method
None
Version Information
InvenTree Version: 1.4.2
API Version: 511
Python Version: 3.14.6
Django Version: 5.2.15
Try to reproduce on the demo site
I did not try to reproduce
Is the bug reproducible on the demo site?
Not reproducible
Relevant log output
Traceback (most recent call last):
File "/root/.local/lib/python3.14/site-packages/django/db/models/query.py", line 948, in get_or_create
return self.get(**kwargs), False
~~~~~~~~^^^^^^^^^^
File "/root/.local/lib/python3.14/site-packages/django/db/models/query.py", line 635, in get
raise self.model.DoesNotExist(
"%s matching query does not exist." % self.model._meta.object_name
)
common.models.NotificationEntry.DoesNotExist: NotificationEntry matching query does not exist.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/.local/lib/python3.14/site-packages/django/db/backends/utils.py", line 105, in _execute
return self.cursor.execute(sql, params)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/root/.local/lib/python3.14/site-packages/psycopg/cursor.py", line 117, in execute
raise ex.with_traceback(None)
psycopg.errors.NumericValueOutOfRange: integer out of range
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/inventree/data/inventree-bambu-plugin/inventree_bambu/notifications.py", line 23, in test_notification
trigger_notification(
~~~~~~~~~~~~~~~~~~~~^
obj=machine,
^^^^^^^^^^^^
...<6 lines>...
check_recent=False,
^^^^^^^^^^^^^^^^^^^
)
^
File "/home/inventree/src/backend/InvenTree/common/notifications.py", line 218, in trigger_notification
common.models.NotificationEntry.notify(category, obj_ref_value)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/inventree/src/backend/InvenTree/common/models.py", line 1661, in notify
entry, _ = cls.objects.get_or_create(key=key, uid=uid)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.14/site-packages/django/db/models/manager.py", line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.14/site-packages/django/db/models/query.py", line 955, in get_or_create
return self.create(**params), True
~~~~~~~~~~~^^^^^^^^^^
File "/root/.local/lib/python3.14/site-packages/django/db/models/query.py", line 665, in create
obj.save(force_insert=True, using=self.db)
~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.14/site-packages/django/db/models/base.py", line 902, in save
self.save_base(
~~~~~~~~~~~~~~^
using=using,
^^^^^^^^^^^^
...<2 lines>...
update_fields=update_fields,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/root/.local/lib/python3.14/site-packages/django/db/models/base.py", line 1008, in save_base
updated = self._save_table(
�
raw,
...<4 lines>...
update_fields,
)
File "/root/.local/lib/python3.14/site-packages/django/db/models/base.py", line 1169, in _save_table
results = self._do_insert(
cls._base_manager, using, fields, returning_fields, raw
)
File "/root/.local/lib/python3.14/site-packages/django/db/models/base.py", line 1210, in _do_insert
return manager._insert(
~~~~~~~~~~~~~~~^
[self],
^^^^^^^
...<3 lines>...
raw=raw,
^^^^^^^^
)
^
File "/root/.local/lib/python3.14/site-packages/django/db/models/manager.py", line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.14/site-packages/django/db/models/query.py", line 1873, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.14/site-packages/django/db/models/sql/compiler.py", line 1882, in execute_sql
cursor.execute(sql, params)
~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/root/.local/lib/python3.14/site-packages/django/db/backends/utils.py", line 79, in execute
return self._execute_with_wrappers(
~~~~~~~~~~~~~~~~~~~~~~~~~~~^
sql, params, many=False, executor=self._execute
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/root/.local/lib/python3.14/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/root/.local/lib/python3.14/site-packages/django/db/backends/utils.py", line 100, in _execute
with self.db.wrap_database_errors:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.14/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/root/.local/lib/python3.14/site-packages/django/db/backends/utils.py", line 105, in _execute
return self.cursor.execute(sql, params)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/root/.local/lib/python3.14/site-packages/psycopg/cursor.py", line 117, in execute
raise ex.with_traceback(None)
django.db.utils.DataError: integer out of range
Activity