codefloe/forgejo-codefloe
Watch
4
12
Fork
You've already forked forgejo-codefloe
0

fix(notifications): don't render release notifications with missing repo/release #40

Merged
pat-s merged 1 commit from fix/notifications-nil-repo-release into v15.0/forgejo-codefloe 2026-06-25 17:39:20 +00:00
Owner

Problem

Opening /notifications 500s with:

Render failed ... user/notification/notification_div:49 : executing ... at <.Repo.Link>:
error calling Link: runtime error: invalid memory address or nil pointer dereference

Root cause

In getNotifications (routers/web/user/notification.go), each release notification's repo/release is loaded in a loop that only logs and continues on failure — but the notification stays in releaseNotifications and is still appended to the unified list with a nil Repo/Release.

The template then evaluates {{.Repo.Link}}. Link() runs on a nil *Repository receiver and dereferences repo.OwnerName, panicking. This happens when a notified release or its repository was deleted.

The issue/PR path already filters failures via notifications.Without(failures); the release path did not.

Fix

  • Collect only successfully-loaded release notifications and drop the rest, mirroring the issue path. Failures now also count towards the existing "removed due to missing parts" flash.
  • Defense-in-depth: guard the release block with {{if and .Repo .Release}} so a nil value can never panic the whole page again.

go build and go vet ./routers/web/user/ pass; template control flow is balanced.

## Problem Opening `/notifications` 500s with: ``` Render failed ... user/notification/notification_div:49 : executing ... at <.Repo.Link>: error calling Link: runtime error: invalid memory address or nil pointer dereference ``` ## Root cause In `getNotifications` (`routers/web/user/notification.go`), each release notification's repo/release is loaded in a loop that only logs and `continue`s on failure — but the notification stays in `releaseNotifications` and is still appended to the unified list with a nil `Repo`/`Release`. The template then evaluates `{{.Repo.Link}}`. `Link()` runs on a nil `*Repository` receiver and dereferences `repo.OwnerName`, panicking. This happens when a notified release or its repository was deleted. The issue/PR path already filters failures via `notifications.Without(failures)`; the release path did not. ## Fix - Collect only successfully-loaded release notifications and drop the rest, mirroring the issue path. Failures now also count towards the existing "removed due to missing parts" flash. - Defense-in-depth: guard the release block with `{{if and .Repo .Release}}` so a nil value can never panic the whole page again. `go build` and `go vet ./routers/web/user/` pass; template control flow is balanced.
fix(notifications): don't render release notifications with missing repo/release
All checks were successful
testing / test-unit (pull_request) Successful in 18m20s
testing / frontend-checks (pull_request) Successful in 2m25s
testing / backend-checks (pull_request) Successful in 14m17s
testing / test-remote-cacher (redict) (pull_request) Successful in 4m4s
testing / test-pgsql (pull_request) Successful in 42m32s
testing / test-remote-cacher (redis) (pull_request) Successful in 5m48s
testing / test-remote-cacher (valkey) (pull_request) Successful in 5m49s
testing / test-e2e (pull_request) Successful in 31m31s
testing / test-remote-cacher (garnet) (pull_request) Successful in 4m8s
testing / test-mysql (pull_request) Successful in 30m17s
testing / test-sqlite (pull_request) Successful in 39m7s
milestone / set (pull_request_target) Has been skipped
issue-labels / backporting (pull_request_target) Has been skipped
e807ae268f
A release notification whose repository or release can no longer be loaded
(e.g. it was deleted) was still appended to the unified notification list with
a nil Repo/Release. The template then evaluated `{{.Repo.Link}}`, calling
`Link()` on a nil `*Repository` receiver, which dereferences `repo.OwnerName`
and panics — taking down the entire /notifications page with a 500.

Drop such notifications in `getNotifications` instead of only logging and
continuing, and count them towards the existing "removed due to missing parts"
flash message. As defense-in-depth, also guard the release block in the
template with `{{if and .Repo .Release}}` so a nil value can never panic the
whole page again.
pat-s merged commit 8c7f619eb9 into v15.0/forgejo-codefloe 2026-06-25 17:39:20 +00:00
pat-s deleted branch fix/notifications-nil-repo-release 2026-06-25 17:39:21 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
codefloe/forgejo-codefloe!40
No description provided.