Skip to content

fix: support UUID notification references - #12616

Merged
SchrodingersGat merged 2 commits into
inventree:masterfrom
FurinaDog:fix/issue-12599-notificationentry-uuid
Aug 11, 2026
Merged

SchrodingersGat merged 2 commits into
inventree:masterfrom
FurinaDog:fix/issue-12599-notificationentry-uuid

Conversation

@FurinaDog

Copy link
Copy Markdown
Contributor

What problem does this solve?

Fixes #12599. NotificationEntry.uid was an IntegerField, but notification deduplication can receive UUID primary keys from models such as MachineConfig. Saving those values caused database errors such as integer out of range.

What changed?

  • Store notification reference IDs in a CharField(max_length=255).
  • Add a migration that preserves existing notification entries while allowing non-integer IDs.
  • Add a regression test covering UUID notification references.

Validation

  • python manage.py migrate --noinput
  • python -m pytest src/backend/InvenTree/common/tests.py -k 'uuid_notification_entry or check_notification_entries' -q --reuse-db (2 passed)
  • python manage.py makemigrations --check --dry-run (no changes detected)

@netlify

netlify Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview canceled.

Name Link
🔨 Latest commit 7ef8407
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6a7ac0f3ddab080008629713

@SchrodingersGat
SchrodingersGat requested review from matmair and a lite review from Copilot August 11, 2026 06:14
@SchrodingersGat SchrodingersGat added bug Identifies a bug which needs to be addressed backport Apply this label to a PR to enable auto-backport action backport-to-1.5.x labels Aug 11, 2026
@SchrodingersGat SchrodingersGat added this to the 1.6.0 milestone Aug 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates notification deduplication tracking so NotificationEntry.uid can store UUID (and other non-integer) primary keys, preventing database errors when notifications reference UUID-backed models.

Changes:

  • Change NotificationEntry.uid from IntegerField to CharField(max_length=255) and widen type hints for check_recent() / notify().
  • Add a schema migration altering the uid field type.
  • Add a regression test ensuring UUID-based notification references are supported.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/backend/InvenTree/common/models.py Switch NotificationEntry.uid to text storage and update method type hints to accept UUIDs.
src/backend/InvenTree/common/migrations/0049_notificationentry_charfield_uid.py Migration to alter the uid column to a CharField(255).
src/backend/InvenTree/common/tests.py New regression test for UUID notification references.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +1659 to +1664
# Notification references may point to models with UUID primary keys.
# Store the value as text so both integer and non-integer identifiers work.
uid = models.CharField(max_length=255)

@classmethod
def check_recent(cls, key: str, uid: int, delta: timedelta):
def check_recent(cls, key: str, uid: str | int | uuid.UUID, delta: timedelta):
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.73%. Comparing base (ad8cb60) to head (7ef8407).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12616      +/-   ##
==========================================
- Coverage   86.73%   86.73%   -0.01%     
==========================================
  Files        1447     1448       +1     
  Lines       96780    96789       +9     
  Branches    11181    11181              
==========================================
+ Hits        83946    83952       +6     
- Misses      12770    12773       +3     
  Partials       64       64              
Flag Coverage Δ
backend 90.77% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend Apps 92.14% <100.00%> (-0.01%) ⬇️
Backend General 93.53% <100.00%> (-0.03%) ⬇️
Frontend 79.61% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SchrodingersGat
SchrodingersGat merged commit 55a193e into inventree:master Aug 11, 2026
42 checks passed
@SchrodingersGat

Copy link
Copy Markdown
Member

@FurinaDog thanks for the contribution 🙂

@github-actions

Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
✅ 1.5.x

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

SchrodingersGat pushed a commit that referenced this pull request Aug 11, 2026
* fix: support UUID notification references

* test: update notification uid expectation

---------


(cherry picked from commit 55a193e)

Co-authored-by: FurinaDog <[email protected]>
Co-authored-by: FurinaDog <[email protected]>
@FurinaDog
FurinaDog deleted the fix/issue-12599-notificationentry-uuid branch August 12, 2026 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Apply this label to a PR to enable auto-backport action backport-to-1.5.x bug Identifies a bug which needs to be addressed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MessageEntry PK Integer assumption.

4 participants