From 59701725d0c4a2fa1b33110438df0ff41f4d9dc3 Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Mon, 27 Apr 2026 18:46:14 +0100 Subject: [PATCH] fix(discussion view): guard against empty comment slice in replies mode Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- pkg/cmd/discussion/view/view.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/cmd/discussion/view/view.go b/pkg/cmd/discussion/view/view.go index 78a5b701a..98b1d608d 100644 --- a/pkg/cmd/discussion/view/view.go +++ b/pkg/cmd/discussion/view/view.go @@ -245,6 +245,9 @@ func viewRun(opts *ViewOptions) error { } defer opts.IO.StopPager() + if len(discussion.Comments.Comments) == 0 { + return fmt.Errorf("no comment found for reply ID %s", opts.Replies) + } comment := discussion.Comments.Comments[0] if opts.IO.IsStdoutTTY() { return printHumanReplies(opts, &comment)