plandex-ai/plandex · error

panic in GetPlanFileResults: %v\n%s

Error message

panic in GetPlanFileResults: %v\n%s

What it means

Each per-file goroutine in GetPlanFileResults has a recover() guard; if the file processing panics (e.g. nil deref, index out of range), the panic is converted into this error carrying the value and a full debug.Stack(), sent on errCh, and the goroutine exits via runtime.Goexit to avoid a double channel send.

Source

Thrown at app/server/db/result_helpers.go:403

	if err != nil {
		if os.IsNotExist(err) {
			return results, nil
		}

		return nil, fmt.Errorf("error reading results dir: %v", err)
	}

	errCh := make(chan error, len(files))
	resultCh := make(chan *PlanFileResult, len(files))

	for _, file := range files {
		// log.Printf("Result file: %s", file.Name())

		go func(file os.DirEntry) {
			defer func() {
				if r := recover(); r != nil {
					log.Printf("panic in GetPlanFileResults: %v\n%s", r, debug.Stack())
					errCh <- fmt.Errorf("panic in GetPlanFileResults: %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(resultsDir, file.Name()))

			if err != nil {
				errCh <- fmt.Errorf("error reading result file: %v", err)
				return
			}

			var result PlanFileResult
			err = json.Unmarshal(bytes, &result)

			if err != nil {
				errCh <- fmt.Errorf("error unmarshalling result file: %v", err)
				return
			}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Read the appended debug.Stack() to find the panicking line
  2. Harden the parsing/population code against nil/zero-value fields
  3. Write a regression test with the offending result file
  4. Keep the recover/Goexit guard — it prevents the panic from crashing the whole process
Defensive patterns

Strategy: try-catch

Try / catch

results, err := db.GetPlanFileResults(orgId, planId)
if err != nil {
    if strings.Contains(err.Error(), "panic in GetPlanFileResults") {
        // stack is embedded in err; report to maintainers with the file contents
    }
    return err
}

Prevention

When it happens

Trigger: Any panic inside the per-file goroutine body: unexpected nil pointers while populating PlanFileResult, slicing errors, or bugs triggered by malformed but parseable JSON content.

Common situations: A result file with valid JSON but unexpected structure (nulls where structs are expected) tripping downstream code; concurrent map access bugs.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/fabdad2dff4f43e3. Report an issue: GitHub.