plandex-ai/plandex · error
panic in GetPlanApplies: %v\n%s
Error message
panic in GetPlanApplies: %v\n%s
What it means
Each goroutine in GetPlanApplies has a recover() deferred handler; if a goroutine panics while processing an apply file, the panic is logged with its stack and converted into this error sent on errCh, which GetPlanApplies then wraps. It indicates an unexpected runtime panic (e.g. nil dereference in future extensions of the loop body) rather than an expected I/O error.
Source
Thrown at app/server/db/result_helpers.go:1051
if err != nil {
if os.IsNotExist(err) {
return nil, nil
}
return nil, fmt.Errorf("error reading applies dir: %v", err)
}
planApplies := []*PlanApply{}
var mu sync.Mutex
errCh := make(chan error, len(files))
for _, file := range files {
go func(file os.DirEntry) {
defer func() {
if r := recover(); r != nil {
log.Printf("panic in GetPlanApplies: %v\n%s", r, debug.Stack())
errCh <- fmt.Errorf("panic in GetPlanApplies: %v\n%s", r, debug.Stack())
runtime.Goexit() // don't allow outer function to continue and double-send to channel
}
}()
bytes, err := os.ReadFile(filepath.Join(appliesDir, file.Name()))
if err != nil {
errCh <- fmt.Errorf("error reading apply file: %v", err)
return
}
var apply PlanApply
err = json.Unmarshal(bytes, &apply)
if err != nil {
errCh <- fmt.Errorf("error unmarshalling apply file: %v", err)
return
}
View on GitHub (pinned to e2d772072e)
Solutions
- Read the debug.Stack() printed to the log to find the panicking line.
- Fix the panicking code to handle nil/unexpected file content defensively.
- Check the apply files in the applies dir for malformed content that triggers the panic path.
Defensive patterns
Strategy: retry
Try / catch
applies, err := GetPlanApplies(orgId, planId)
if err != nil && strings.Contains(err.Error(), "panic in GetPlanApplies") {
// stack trace is in the server log; escalate with that context
return nil, fmt.Errorf("internal panic while listing applies, see server log: %w", err)
} Prevention
- Keep nil checks around every value extracted inside the per-file goroutine.
- Test the applies loop with malformed and empty files to catch panic paths early.
- Monitor server logs for panic stack traces and fix the root line they point to.
When it happens
Trigger: Any runtime panic inside the per-file goroutine — nil pointer dereference or slice-out-of-range while handling file contents. With the current body this is rare; it becomes relevant when the loop body is extended.
Common situations: Custom-modified builds of this function added processing logic that panics on unexpected file content; out-of-memory-style edge cases in JSON handling.
Related errors
- panic in UpdateContexts: %v\n%s
- panic in GetPlanConvo: %v\n%s
- panic in gitRemoveIndexLockFileIfExists: %v %s
- panic in SyncPlanTokens: %v %s
- panic in DeleteDraftPlans: %v %s
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/3c7671f5b41bd41f.
Report an issue: GitHub.