Skip to content

Notification UUID/PK Triggering Error #12131

Closed

Description

@psxjt5

Please verify that this bug has NOT been raised before.

  • I checked and didn't find a similar issue

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...

^

Activity

  1. added
    bug
    question
    triage:not-checked
    on Jun 9, 2026
  2. added a commit that references this issue on Jun 14, 2026
    9706bc6
  3. removed
    triage:not-checked
    on Jun 15, 2026
  4. added theissue type on Jun 15, 2026
  5. added this to the 1.4.0 milestone on Jun 15, 2026
  6. added 2 commits that reference this issue on Jun 30, 2026
    d47d258
    9bd06ad
  7. added a commit that references this issue on Aug 4, 2026
    f395ae8
  8. psxjt5 commented on Aug 10, 2026

    @psxjt5
    ContributorAuthor

    Thanks for addressing this issue, notifications are now being sent through.

    I've added a follow-up issue #12599 as I believe that there is a similar problem in the MessageEntry class (integer assumption where a UUID can be passed in), which is causing an issue when messages are raised.

    Thanks,
    James.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugquestion

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions