{"record":{"id":"756c88e6ffd65a2c","repo":"plandex-ai/plandex","slug":"panic-in-genpipeddataname-v-s","errorCode":null,"errorMessage":"panic in GenPipedDataName: %v\n%s","messagePattern":"panic in GenPipedDataName: (.+?)\n(.+?)","errorType":"panic","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/context_helper.go","lineNumber":154,"sourceCode":"\t\t\t\tlog.Printf(\"Error loading context: %s does not support images in context\\n\", settings.GetModelPack().Planner.ModelId)\n\t\t\t\thttp.Error(w, fmt.Sprintf(\"Error loading context: %s does not support images in context\", settings.GetModelPack().Planner.ModelId), http.StatusBadRequest)\n\t\t\t\treturn nil, nil\n\t\t\t}\n\t\t}\n\t}\n\n\t// get name for piped data or notes if present\n\tnum := 0\n\terrCh := make(chan error, len(*loadReq))\n\tfor _, context := range *loadReq {\n\t\tif context.ContextType == shared.ContextPipedDataType {\n\t\t\tnum++\n\n\t\t\tgo func(context *shared.LoadContextParams) {\n\t\t\t\tdefer func() {\n\t\t\t\t\tif r := recover(); r != nil {\n\t\t\t\t\t\tlog.Printf(\"panic in GenPipedDataName: %v\\n%s\", r, debug.Stack())\n\t\t\t\t\t\terrCh <- fmt.Errorf(\"panic in GenPipedDataName: %v\\n%s\", r, debug.Stack())\n\t\t\t\t\t\truntime.Goexit() // don't allow outer function to continue and double-send to channel\n\t\t\t\t\t}\n\t\t\t\t}()\n\n\t\t\t\tname, err := model.GenPipedDataName(model.GenPipedDataNameParams{\n\t\t\t\t\tCtx:           r.Context(),\n\t\t\t\t\tAuth:          auth,\n\t\t\t\t\tPlan:          plan,\n\t\t\t\t\tSettings:      settings,\n\t\t\t\t\tAuthVars:      authVars,\n\t\t\t\t\tSessionId:     context.SessionId,\n\t\t\t\t\tClients:       clients,\n\t\t\t\t\tPipedContent:  context.Body,\n\t\t\t\t\tOrgUserConfig: orgUserConfig,\n\t\t\t\t})\n\n\t\t\t\tif err != nil {\n\t\t\t\t\terrCh <- fmt.Errorf(\"error generating name for piped data: %v\", err)","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/context_helper.go#L136-L172","documentation":"A panic occurred inside the goroutine calling model.GenPipedDataName; the deferred recover() captures it and converts it into an error carrying the panic value and a debug.Stack() trace, sent to errCh.","triggerScenarios":"A worker goroutine for piped-data naming panics — e.g. nil dereference in context.Body handling, unexpected piped content type, or a nil client/OrgUserConfig reaching the model.","commonSituations":"Unusual piped content (binary, deeply nested attachments) tripping model code; nil pointer when Body or clients are unset; model version change introducing a panic path on new content shapes.","solutions":["Read the embedded debug.Stack() in the error to find the panic site","Check which goroutine input was nil or malformed (Body, clients, orgUserConfig)","Pre-validate piped content shape before dispatching goroutines","Update/patch the model code at the panic site to handle the offending input"],"exampleFix":"// before\ndefer func() {\n\tif r := recover(); r != nil {\n\t\terrCh <- fmt.Errorf(\"panic in GenPipedDataName: %v\\n%s\", r, debug.Stack())\n\t\truntime.Goexit()\n\t}\n}()\n// after\n// keep recover, but guard inputs before spawning:\nif context == nil || context.Body == nil {\n\terrCh <- fmt.Errorf(\"invalid piped data context: nil body\")\n\treturn\n}","handlingStrategy":"try-catch","validationCode":"// guard inputs before dispatching the naming goroutine\nif context == nil || context.Body == nil {\n\treturn errors.New(\"piped data context or body is nil\")\n}","typeGuard":"func validPipedContext(c *shared.LoadContextParams) bool {\n\treturn c != nil && c.Body != nil\n}","tryCatchPattern":"// errors arrive via errCh\nfor range contexts {\n\tif err := <-errCh; err != nil {\n\t\tif strings.HasPrefix(err.Error(), \"panic in GenPipedDataName\") {\n\t\t\tlog.Printf(\"naming panicked, stack: %s\", err.Error())\n\t\t\tcontinue // skip item rather than failing whole request\n\t\t}\n\t\treturn err\n\t}\n}","preventionTips":["Always recover() in worker goroutines and forward the stack","Nil-check Body/clients/orgUserConfig before spawning goroutines","Add fuzz/edge tests for unusual piped content shapes","Keep debug.Stack() in the message for postmortems"],"tags":["panic","concurrency","goroutine"],"backgroundTag":"panic-in-goroutine","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}