plandex-ai/plandex · error
err.Error()
Error message
err.Error()
What it means
When rendering diffs as an HTML page in the local web server started by the CLI, template execution (tmpl.Execute) can fail. The handler writes err.Error() to the HTTP response with status 500, so the browser shows the raw Go template error text. It means the template and the data passed to it are incompatible (bad field references, wrong types).
Source
Thrown at app/cli/cmd/diffs.go:124
term.OutputErrorAndExit("Error parsing template: %v", err)
}
// Use :0 to let the OS pick an available port
listener, err := net.Listen("tcp", ":0")
if err != nil {
term.OutputErrorAndExit("Error starting server: %v", err)
}
// Get the actual port chosen
port := listener.Addr().(*net.TCPAddr).Port
// Start web server
go func() {
http.HandleFunc("/"+outputFormat, func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
err := tmpl.Execute(w, data)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
})
http.Serve(listener, nil)
}()
ui.OpenURL("Showing "+outputFormat+" diffs in your default browser...", fmt.Sprintf("http://localhost:%d/%s", port, outputFormat))
fmt.Println()
return listener
}
listener := getNewListener()
defer listener.Close()
var relaunch bool
for {View on GitHub (pinned to e2d772072e)
Solutions
- Read the error message shown in the browser — it names the exact template field or parse problem
- Update the CLI to the latest version so template and data struct are back in sync
- Re-run the command; if persistent, use a non-HTML output format (e.g. plain text diff) as a workaround
- Check port conflicts / stale server processes and restart so the handler is freshly registered
Example fix
// before
err := tmpl.Execute(w, data)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
// after
err := tmpl.Execute(w, data)
if err != nil {
log.Printf("template execute failed: %v", err)
http.Error(w, "failed to render diffs", http.StatusInternalServerError)
} Defensive patterns
Strategy: try-catch
Try / catch
if err := tmpl.Execute(w, data); err != nil {
log.Printf("template error: %v", err)
http.Error(w, "failed to render diffs", http.StatusInternalServerError)
} Prevention
- Keep embedded templates and data structs in sync with tests
- Use template.ExecuteTemplate with parsed-and-validated templates at startup
- Prefer plain-text diff output in scripts
When it happens
Trigger: Running `diffs` with an HTML output format; the diff data struct passed to the template lacks a field the template references, or the template file itself has invalid syntax, causing tmpl.Execute to return an error at request time.
Common situations: Upgrading the CLI where the embedded template and data struct drifted out of sync; viewing very large diffs that time out or get truncated mid-template; malformed template assets on a customized install.
Related errors
- error selecting account: account not found
- error signing in: %v
- error selecting or signing in to account: %v
- error selecting sign in option: %v
- error prompting host: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/dace81b083eb4840.
Report an issue: GitHub.