plandex-ai/plandex · error
error writing result file: %v
Error message
error writing result file: %v
What it means
StorePlanResult marshals the result and writes it to resultsDir/<id>.json via os.WriteFile. If the write fails (permissions, disk full, I/O error, dir vanished between MkdirAll and WriteFile) it wraps the OS error with this message.
Source
Thrown at app/server/db/result_helpers.go:49
if err != nil {
return fmt.Errorf("error marshalling result: %v", err)
}
resultsDir := getPlanResultsDir(result.OrgId, result.PlanId)
err = os.MkdirAll(resultsDir, 0755)
if err != nil {
return fmt.Errorf("error creating results dir: %v", err)
}
log.Printf("Storing plan result: %s - %s", result.Path, result.Id)
err = os.WriteFile(filepath.Join(resultsDir, result.Id+".json"), bytes, 0644)
if err != nil {
return fmt.Errorf("error writing result file: %v", err)
}
return nil
}
type CurrentPlanStateParams struct {
OrgId string
PlanId string
PlanFileResults []*PlanFileResult
ConvoMessageDescriptions []*ConvoMessageDescription
Contexts []*Context
}
func GetFullCurrentPlanStateParams(orgId, planId string) (CurrentPlanStateParams, error) {
errCh := make(chan error, 3)
var results []*PlanFileResultView on GitHub (pinned to e2d772072e)
Solutions
- Read the wrapped os.PathError to identify path and errno (ENOSPC, EACCES, ENOENT)
- Check free disk space and quotas on the data volume
- Verify directory permissions for the server process user
- Retry once after confirming the results dir exists (guard against racing deletion)
- Avoid restarting the plan write pipeline until storage is healthy to prevent partial results
Example fix
// before
err := db.StorePlanResult(result)
// after
if err := db.StorePlanResult(result); err != nil {
var pathErr *os.PathError
if errors.As(err, &pathErr) && errors.Is(pathErr.Err, syscall.ENOSPC) {
return fmt.Errorf("out of disk space while storing result %s", result.Id)
}
return err
} Defensive patterns
Strategy: try-catch
Validate before calling
func writable(dir string) bool {
f, err := os.CreateTemp(dir, ".w-*")
if err != nil {
return false
}
f.Close()
os.Remove(f.Name())
return true
}
// call writable(getPlanResultsDir(orgId, planId)) before storing Type guard
func isNoSpace(err error) bool {
var pe *os.PathError
return errors.As(err, &pe) && errors.Is(pe.Err, syscall.ENOSPC)
} Try / catch
if err := db.StorePlanResult(result); err != nil {
if isNoSpace(err) {
alertOps("disk full")
}
return fmt.Errorf("StorePlanResult(%s): %w", result.Id, err)
} Prevention
- Alert on disk usage thresholds well before 100%
- Use atomic write (temp file + rename) to avoid partial results
- Don't run cleanup jobs concurrently with writes, or make them idempotent
- Keep result.Id as a generated UUID (the code already does this) so paths are safe
- Remount read-only volumes and restart before resuming writes
When it happens
Trigger: os.WriteFile fails when storing a plan result: read-only filesystem, disk quota/full disk, race where another process deleted the results directory, or the result.Id contains path-hostile characters.
Common situations: Disk-full on the server after a large plan; container volume remounted read-only; concurrent cleanup job removing results dir mid-write; running the server under a different user than the one that owns the data dir.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- error writing convo message description: %v
- error writing current plan settings: %v
- error reading settings-v2.json: %v
- failed to seek in temporary file: %w
- error reading convo dir: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/ea2df1c42f12cbcc.
Report an issue: GitHub.