From 3cf1a74876f5576f05257996f2246db4c41343c6 Mon Sep 17 00:00:00 2001 From: Jeff Halter <868228+jhalter@users.noreply.github.com> Date: Sun, 30 Nov 2025 20:27:30 -0800 Subject: Fix panic when posting article to empty news category --- internal/mobius/threaded_news.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/mobius/threaded_news.go b/internal/mobius/threaded_news.go index f785bdf..eae2349 100644 --- a/internal/mobius/threaded_news.go +++ b/internal/mobius/threaded_news.go @@ -135,10 +135,18 @@ func (n *ThreadedNewsYAML) PostArticle(newsPath []string, parentArticleID uint32 } cats := n.getCatByPath(newsPath[:len(newsPath)-1]) + if cats == nil { + return fmt.Errorf("parent category path does not exist") + } catName := newsPath[len(newsPath)-1] cat := cats[catName] + // Initialize Articles map if nil (e.g., from old YAML files) + if cat.Articles == nil { + cat.Articles = make(map[uint32]*hotline.NewsArtData) + } + var keys []int for k := range cat.Articles { keys = append(keys, int(k)) -- cgit