Bug: nil pointer dereference crash during build of large files ("Error building race")
Author: drkover-maxCreated Jun 3, 2026Updated Jun 3, 2026
Description
Plandex server crashes with a nil pointer dereference when building large file replacements. The error occurs during the build/merge phase after the LLM has successfully generated the file content. It reproduces consistently on files over ~10,000 tokens (e.g., LIVE_STATE.md at 14,555 tokens, DECISIONS.md at similar size).
Error message
Build incomplete
LIVE_STATE.md .:
Error building race
-> All build attempts failed
-> [error building validate loop: runtime error: invalid memory address or nil pointer dereference
ce error starting whole file build: runtime error: invalid memory address or nil pointer dereference]Steps to reproduce
- Create a plan with a large markdown file in context (~14,000+ tokens)
- Run
plandex tellwith a prompt that rewrites or heavily modifies that file - The LLM streams the full file content successfully
- The build phase crashes with the nil pointer dereference before the file can be applied
Environment
- Server:
plandexai/plandex-server:latestDocker image (pulled 2026-06-03) - Deployment: Local mode via
docker compose up -don Google Cloud Shell - Database: PostgreSQL 16
- Model pack:
google(Gemini models) - CLI: Plandex CLI, local mode, connected to localhost:8099
- auto-mode: false (manual apply)
Additional context
- Reproduced twice in the same session with different prompts, both targeting the same large files
- First run: PLAN.md (smaller file) built successfully, then crashed on LIVE_STATE.md
- Second run: crashed again on LIVE_STATE.md during the build phase
- The LLM output streams correctly each time; the crash is in the server-side build/merge logic, not in model generation
- Smaller files (e.g., PLAN.md at ~1,450 tokens) build without issues in the same session
Workaround
For large file edits, apply changes directly via shell tools (sed, python scripts) instead of through plandex tell. Only use Plandex for smaller file modifications.
Source: plandex-ai/plandex