Please verify that this bug has NOT been raised before.
Describe the bug*
I'm trying to get a notification to trigger from a plugin that I'm writing:
from common.notifications import trigger_notification
from django.contrib.auth import get_user_model
from machine.models import MachineConfig
class Notifications:
def test_notification(machine):
User = get_user_model()
user = User.objects.filter(is_superuser=True)
machine = MachineConfig.objects.get(pk=machine.pk)
trigger_notification(
obj=machine,
category="system",
targets=user,
context={
"name": "Test",
"message": "Hello world",
},
check_recent=False,
)
But I'm getting an error (trace in the Issue Log Output Field) when this method is called.
If I set obj=None, the notification triggers (however I get an error about it being Null and when I click on the notification, InvenTree obviously doesn't know where to navigate to).
I believe it has something to do with the fact that the MachineConfig class uses a UUID as an id (id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)), and the NotificationMessage is then trying to cast this to an int (target_object_id = models.PositiveIntegerField()).
Am I providing the wrong obj value here or is something else going wrong?
Thanks,
James.
Steps to Reproduce
Call trigger_notification where obj is passed a MachineConfig instance.
Expected behaviour
The notification is visible within the UI and the error does not occur.
Deployment Method
Docker
Version Information
InvenTree Version: 1.2.4
API Version: 453
Python Version: 3.11.14
Django Version: 5.2.11
Commit Hash: 4789a20
Commit Date: 2026-03-17
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.11/site-packages/django/db/backends/utils.py", line 105, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/psycopg/cursor.py", line 117, in execute
raise ex.with_traceback(None)
psycopg.errors.NumericValueOutOfRange: value "137023719040805274638741863464503989598" is out of range for type integer
LINE 1: ...CT * FROM UNNEST(('{73,73}'::int2[])::integer[], ('{13702371...
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/inventree/src/backend/InvenTree/common/notifications.py", line 211, in trigger_notification
if plugin.send_notification(obj, category, filtered_users, context):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/inventree/src/backend/InvenTree/plugin/builtin/integration/core_notifications.py", line 58, in send_notification
NotificationMessage.objects.bulk_create(entries)
File "/root/.local/lib/python3.11/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.11/site-packages/django/db/models/query.py", line 825, in bulk_create
returned_columns = self._batched_insert(
^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/django/db/models/query.py", line 1901, in _batched_insert
self._insert(
File "/root/.local/lib/python3.11/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.11/site-packages/django/db/models/sql/compiler.py", line 1882, in execute_sql
cursor.execute(sql, params)
File "/root/.local/lib/python3.11/site-packages/django/db/backends/utils.py", line 79, in execute
return self._execute_with_wrappers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
return executor(sql, params, many, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/django/db/backends/utils.py", line 100, in _execute
with self.db.wrap_database_errors:
File "/root/.local/lib/python3.11/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.11/site-packages/django/db/backends/utils.py", line 105, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/psycopg/cursor.py", line 117, in execute
raise ex.with_traceback(None)
django.db.utils.DataError: value "137023719040805274638741863464503989598" is out of range for type integer
LINE 1: ...CT * FROM UNNEST(('{73,73}'::int2[])::integer[], ('{13702371...
^
Please verify that this bug has NOT been raised before.
Describe the bug*
I'm trying to get a notification to trigger from a plugin that I'm writing:
But I'm getting an error (trace in the Issue Log Output Field) when this method is called.
If I set
obj=None, the notification triggers (however I get an error about it being Null and when I click on the notification, InvenTree obviously doesn't know where to navigate to).I believe it has something to do with the fact that the
MachineConfigclass uses a UUID as an id (id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)), and the NotificationMessage is then trying to cast this to an int (target_object_id = models.PositiveIntegerField()).Am I providing the wrong obj value here or is something else going wrong?
Thanks,
James.
Steps to Reproduce
Call
trigger_notificationwhereobjis passed a MachineConfig instance.Expected behaviour
The notification is visible within the UI and the error does not occur.
Deployment Method
Docker
Version Information
InvenTree Version: 1.2.4
API Version: 453
Python Version: 3.11.14
Django Version: 5.2.11
Commit Hash: 4789a20
Commit Date: 2026-03-17
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