From 32577c91f4748276e163c858cf6fdc2b95899423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Fri, 13 Mar 2026 01:13:44 +0100 Subject: [PATCH] fix: return error instead of panic in ResolveAttachments; fix wrong slice index in log Two issues in attachment handling: 1. GetAttachments failure called panic(err) instead of returning an error, crashing the process on any API failure. 2. The 'keeping unmodified' log loop indexed into the original attachments slice using the range of existing, causing wrong names to be logged and a potential out-of-bounds panic when existing is longer than attachments. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- attachment/attachment.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/attachment/attachment.go b/attachment/attachment.go index 727ec9f..ac4573e 100644 --- a/attachment/attachment.go +++ b/attachment/attachment.go @@ -61,7 +61,7 @@ func ResolveAttachments( remotes, err := api.GetAttachments(page.ID) if err != nil { - panic(err) + return nil, karma.Format(err, "unable to get attachments for page %s", page.ID) } existing := []Attachment{} @@ -153,7 +153,7 @@ func ResolveAttachments( } for i := range existing { - log.Infof(nil, "keeping unmodified attachment: %q", attachments[i].Name) + log.Infof(nil, "keeping unmodified attachment: %q", existing[i].Name) } attachments = []Attachment{}