{"record":{"id":"455ab1b82d515ae9","repo":"immich-app/immich","slug":"notification-not-found","errorCode":null,"errorMessage":"Notification not found","messagePattern":"Notification not found","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"server/src/services/notification.service.ts","lineNumber":58,"sourceCode":"  }\n\n  async updateAll(auth: AuthDto, dto: NotificationUpdateAllDto) {\n    await this.requireAccess({ auth, ids: dto.ids, permission: Permission.NotificationUpdate });\n    await this.notificationRepository.updateAll(dto.ids, {\n      readAt: dto.readAt,\n    });\n  }\n\n  async deleteAll(auth: AuthDto, dto: NotificationDeleteAllDto) {\n    await this.requireAccess({ auth, ids: dto.ids, permission: Permission.NotificationDelete });\n    await this.notificationRepository.deleteAll(dto.ids);\n  }\n\n  async get(auth: AuthDto, id: string) {\n    await this.requireAccess({ auth, ids: [id], permission: Permission.NotificationRead });\n    const item = await this.notificationRepository.get(id);\n    if (!item) {\n      throw new BadRequestException('Notification not found');\n    }\n    return mapNotification(item);\n  }\n\n  async update(auth: AuthDto, id: string, dto: NotificationUpdateDto) {\n    await this.requireAccess({ auth, ids: [id], permission: Permission.NotificationUpdate });\n    const item = await this.notificationRepository.update(id, {\n      readAt: dto.readAt,\n    });\n    return mapNotification(item);\n  }\n\n  async delete(auth: AuthDto, id: string) {\n    await this.requireAccess({ auth, ids: [id], permission: Permission.NotificationDelete });\n    await this.notificationRepository.delete(id);\n  }\n\n  @OnJob({ name: JobName.NotificationsCleanup, queue: QueueName.BackgroundTask })","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/server/src/services/notification.service.ts#L40-L76","documentation":"Thrown by NotificationService.get when no notification exists for the given id, after access control passes. The repository returns undefined and the service raises a BadRequestException instead of returning a null/mapped object. In practice this means the notification id is unknown, stale, or already deleted.","triggerScenarios":"GET /notifications/:id with an id that does not exist in the database, was already dismissed/deleted, or is malformed/points to another instance's data.","commonSituations":"Client caches or bookmarks a notification id that has since been removed; UI re-loads a stale list after cleanup job deleted rows; copy-pasted id from another environment; double-click causing the first request to delete/consume the notification.","solutions":["Verify the notification id is correct and still exists (e.g. re-fetch the notification list)","Refresh the client's notification list to drop stale ids before retrying","Handle 400 'Notification not found' on the client by removing the item from local state","If ids come from another environment, use the correct instance's ids"],"exampleFix":"// before\nconst n = await api.notificationApi.getNotificationById(staleId); // throws 400\n// after\nconst list = await api.notificationApi.getNotifications();\nconst n = list.find(x => x.id === staleId);\nif (n) { /* use it */ } else { removeFromLocalState(staleId); }","handlingStrategy":"validation","validationCode":"const list = await api.notificationApi.getNotifications();\nif (!list.some(n => n.id === id)) {\n  throw new Error(`Notification ${id} no longer exists; refresh list`);\n}","typeGuard":"function isKnownNotification(id, notifications) {\n  return typeof id === 'string' && id.length > 0 &&\n    notifications.some(n => n && typeof n.id === 'string' && n.id === id);\n}","tryCatchPattern":"try {\n  const n = await api.notificationApi.getNotificationById(id);\n  return n;\n} catch (e) {\n  if (String(e.message).includes('Notification not found')) {\n    removeFromLocalState(id); // drop stale id, optionally refetch list\n    return null;\n  }\n  throw e;\n}","preventionTips":["Refresh the notification list after delete/dismiss operations","Never reuse ids across environments or instances","Treat 400 'Notification not found' as a stale-cache signal, not a bug","Remove consumed notifications from client state immediately"],"tags":["not-found","notifications","rest-api"],"backgroundTag":"record-not-found","analyzedSha":"e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c","analyzedAt":"2026-09-15T07:20:19.675Z","contentChangedAt":"2026-09-15T07:20:19.675Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}