#7797·PeerTube

TypeError crash when rendering notification list — orphaned notifications after changeOwnership deletion

Author: valeron90Created Sep 26, 2026Updated Sep 26, 2026

Describe the current behavior

Opening the notifications popover crashes the Angular frontend with:

ERROR TypeError: Cannot read properties of undefined (reading 'initiatorAccount')
at yt (chunk-XXX.js:1:11426)
...
loadNotifications @ chunk-XXX.js:1
ngOnInit @ chunk-XXX.js:1
The crash happens while rendering the notification list. Root cause: the GET /api/v1/users/me/notifications response contains notifications of type 26 (VIDEO_OWNERSHIP_CHANGED_REQUEST) and 27 (VIDEO_OWNERSHIP_CHANGED_ACCEPTED) without the changeOwnership payload field, because the referenced changeOwnership DB row no longer exists. The template in user-notification-content.component.html unconditionally accesses n.payload.changeOwnership.initiatorAccount / nextOwnerAccount, so one orphaned notification crashes the entire popover.

In the database, the affected notifications have changeOwnershipId = NULL (or pointing to a deleted row):

id | type | changeOwnershipId
-------+------+-------------------
24038 | 26 |
24039 | 27 |
Deleting these rows fixes the crash.

Steps to reproduce

User A initiates a video ownership transfer to user B (this creates a changeOwnership row and a type-26 notification for B). User B accepts the transfer (this creates a type-27 notification for A). The changeOwnership row is then removed — e.g. because the video involved in the transfer is deleted. Any user with such an orphaned notification opens the notifications popover → the client crashes with the TypeError above and the notification list does not render.

Describe the expected behavior

When a changeOwnership row is deleted (directly or via cascade from video/channel deletion), the associated userNotification rows should be deleted as well (FK cascade or explicit cleanup). The notification serializer / client template should handle a missing changeOwnership payload gracefully (e.g. skip the notification or render a fallback text) instead of crashing the whole list.

Additional information

  • Version: 8.3.0

  • NodeJS version: v22.23.3

  • Ffmpeg version: 7.1.5-0+deb13u1

  • Browser name, version and platforms on which you could reproduce the bug:
    Brave. Chrome

  • Link to browser console log if relevant:
    TypeError: Cannot read properties of undefined (reading 'initiatorAccount')
    thrown during loadNotifications / ngOnInit of the notification popover

  • Link to server log if relevant:
    N/A — GET /api/v1/users/me/notifications returns HTTP 200 with the incomplete
    payload (notifications of type 26/27 without the "changeOwnership" field);
    the failure is client-side.