{"record":{"id":"3c7518332a6e94b7","repo":"plandex-ai/plandex","slug":"panic-in-addplanconvomessage-v-s","errorCode":null,"errorMessage":"panic in AddPlanConvoMessage: %v\n%s","messagePattern":"panic in AddPlanConvoMessage: (.+?)\n(.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/plan_helpers.go","lineNumber":149,"sourceCode":"\treturn namesMap, nil\n}\n\nfunc AddPlanContextTokens(planId, branch string, addTokens int) error {\n\t_, err := Conn.Exec(\"UPDATE branches SET context_tokens = context_tokens + $1 WHERE plan_id = $2 AND name = $3\", addTokens, planId, branch)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error updating plan tokens: %v\", err)\n\t}\n\treturn nil\n}\n\nfunc AddPlanConvoMessage(msg *ConvoMessage, branch string) error {\n\terrCh := make(chan error, 2)\n\n\tgo func() {\n\t\tdefer func() {\n\t\t\tif r := recover(); r != nil {\n\t\t\t\tlog.Printf(\"panic in AddPlanConvoMessage: %v\\n%s\", r, debug.Stack())\n\t\t\t\terrCh <- fmt.Errorf(\"panic in AddPlanConvoMessage: %v\\n%s\", r, debug.Stack())\n\t\t\t\truntime.Goexit() // don't allow outer function to continue and double-send to channel\n\t\t\t}\n\t\t}()\n\n\t\t_, err := Conn.Exec(\"UPDATE branches SET convo_tokens = convo_tokens + $1 WHERE plan_id = $2 AND name = $3\", msg.Tokens, msg.PlanId, branch)\n\n\t\tif err != nil {\n\t\t\terrCh <- fmt.Errorf(\"error updating plan tokens: %v\", err)\n\t\t\treturn\n\t\t}\n\n\t\terrCh <- nil\n\t}()\n\n\tgo func() {\n\t\tdefer func() {\n\t\t\tif r := recover(); r != nil {\n\t\t\t\tlog.Printf(\"panic in AddPlanConvoMessage: %v\\n%s\", r, debug.Stack())","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/plan_helpers.go#L131-L167","documentation":"Recovery guard inside AddPlanConvoMessage's goroutine: a panic occurred while persisting the convo message; the panic value and stack are logged and converted into this returned error instead of crashing the server.","triggerScenarios":"Thrown at app/server/db/plan_helpers.go:149 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the logged stack trace to find the panicking code path","Check for nil fields on the ConvoMessage being inserted","Fix the underlying nil-deref/bug; the recover is only a safety net"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}