createNotification returns an id that does not match the file the notify script writes

Đang mở
#2,140 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
50/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
graphql, typescript
Lĩnh vực
api, backend

Hướng nghiên cứu

Start in NotificationsService.createNotification(), where makeNotificationId() builds the returned id, and compare it with the file name the legacy notify script writes (safe_filename("{event}-{unix timestamp}.notify")). Trace the unread/archive lookup used by archiveNotification and deleteNotification, and check notifyIfUnique for when browser notifications are off. Done when the returned id and type resolve to the file actually written, and repeated notifyIfUnique calls do not duplicate the notification.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Environment

Unraid OS Version: 7.3.4 (API 4.37.9+bedd403a)

Are you using a reverse proxy? No. Tested directly against the server's built-in /graphql endpoint, authenticated with an x-api-key (ADMIN role).

Hardware / setup that may matter: Supermicro X12STH-F, Xeon E-2356G. Settings > Notifications has browser notifications turned off and agents only for every level (normal="4", warning="4", alert="4" in dynamix.cfg). The id mismatch below happens with any settings; the other two problems only show up with browser notifications turned off.

Pre-submission Checklist

  • I have verified that my Unraid OS is up to date
  • I have tested this issue by accessing my server directly (not through a reverse proxy)
  • This is not an Unraid Connect related issue (if it is, please submit via the support form instead)

Issue Description

createNotification returns an id that does not match the notification it creates, so the returned id cannot be used to archive, read or delete it.

NotificationsService.createNotification() builds an id with makeNotificationId() (title + UUIDv7), then hands the notification to the legacy /usr/local/emhttp/webGui/scripts/notify script. The script picks its own file name, safe_filename("{event}-{unix timestamp}.notify"). The service only writes a file under its own id if the script fails, but it always returns its own id. Unchanged on main.

With browser notifications turned off there are two more problems:

  1. The notify script always writes the archive copy, but only writes an unread copy when the browser bit (entity & 1) is set for that importance level. The mutation still returns type: UNREAD, but nothing is in the unread list.
  2. notifyIfUnique only checks the unread list for duplicates, so on these servers it never finds one and creates a new notification every time.

Steps to Reproduce

  1. mutation { createNotification(input: {title: "API test", subject: "s", description: "d", importance: INFO}) { id type } }
  2. Returned id: <server-id>:API_test_01a19e36-9055-7367-87c9-1014cf3dc06d.notify. File actually written: /tmp/notifications/archive/API_test_1793655738.notify (no unread copy, because of the settings above).
  3. mutation { archiveNotification(id: "<returned id>") { id } } fails.
  4. mutation { deleteNotification(id: "<returned id>", type: ARCHIVE) { archive { total } } } fails.
  5. query { notifications { list(filter: {type: ARCHIVE, offset: 0, limit: 50}) { id title } } } shows the notification with id <server-id>:API_test_1793655738.notify. Deleting with that id works.
  6. Run notifyIfUnique twice with the same input. It returns two different ids and two archive files are created (API_dedupe_test_1793656186.notify, API_dedupe_test_1793656187.notify).

Expected Behavior

  • The id returned by createNotification is the id of the notification that was created, and works with archiveNotification, deleteNotification and unreadNotification.
  • The returned type matches where the notification actually ended up.
  • notifyIfUnique does not create a duplicate when browser notifications are turned off.

Actual Behavior

Step 3:

{"errors":[{"message":"Could not find notification in unreads: API_test_01a19e36-9055-7367-87c9-1014cf3dc06d.notify"}]}

Step 4:

{"errors":[{"message":"ENOENT: no such file or directory, open '/tmp/notifications/archive/API_test_01a19e36-9055-7367-87c9-1014cf3dc06d.notify'"}]}

Additional Context

Possible fixes: have the service compute the same file name the script will use (or pass it to the script), or look up the file the script created and return that id and type. For notifyIfUnique, also check recent archive entries when browser notifications are turned off for that importance level.

Ngôn ngữ chính
TypeScript
Star
123
Fork
25
Merge trung bình
2 ngày 16 giờ
Pull request đã merge (30 ngày)
9

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của unraid/api

Tất cả issue của unraid/api

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.