From 279c0d0e6ca94a7a323fd2778bf090d7dff8ceb5 Mon Sep 17 00:00:00 2001 From: Castor Gemini Date: Fri, 22 Aug 2025 00:36:54 -0500 Subject: [PATCH] fix: Add diagnostic check for nil chat entries --- main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.go b/main.go index a05c617..49c1dc2 100644 --- a/main.go +++ b/main.go @@ -55,6 +55,17 @@ func main() { if argv.Add != "" { me.chats.AddFile(argv.Add) + + // --- Start Diagnostic Check --- + // This loop will check for nil entries in the slice before marshaling. + for i, chat := range me.chats.GetChats() { + if chat == nil { + log.Fatalf("Found a nil *Chat pointer at index %d before calling ConfigSave(). This is the cause of the panic.", i) + } + } + log.Info("Sanity check passed: No nil entries found in the Chats slice.") + // --- End Diagnostic Check --- + me.chats.ConfigSave() okExit("") }