JuliusBrussee/caveman · error
export directory is required
Error message
export directory is required
What it means
Returned by Store.ExportTrial when outDir is the empty string. ExportTrial writes trial.json and spans.jsonl into the directory, and it refuses to run without an explicit destination directory (it would otherwise scatter files into the process CWD or fail confusingly).
Source
Thrown at proxy/internal/store/report.go:116
return fmt.Errorf("report path is required")
}
if err := os.MkdirAll(filepath.Dir(outPath), 0o700); err != nil {
return err
}
f, err := os.OpenFile(outPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o600)
if err != nil {
return err
}
defer f.Close()
return trialTemplate.Execute(f, struct {
Plan TrialPlan
Generated string
}{Plan: plan, Generated: time.Now().UTC().Format(time.RFC3339)})
}
func (s *Store) ExportTrial(plan TrialPlan, outDir string) (map[string]string, error) {
if outDir == "" {
return nil, fmt.Errorf("export directory is required")
}
if err := os.MkdirAll(outDir, 0o700); err != nil {
return nil, err
}
trialPath := filepath.Join(outDir, "trial.json")
raw, _ := json.MarshalIndent(plan, "", " ")
if err := os.WriteFile(trialPath, append(raw, '\n'), 0o600); err != nil {
return nil, err
}
spansPath := filepath.Join(outDir, "spans.jsonl")
f, err := os.OpenFile(spansPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o600)
if err != nil {
return nil, err
}
if err := s.writeExportSpans(f, plan); err != nil {
_ = f.Close()
return nil, err
}View on GitHub (pinned to 27d5a3981a)
Solutions
- Require the export-dir flag at the CLI layer and fail with a usage message before calling ExportTrial
- Default it to a deterministic location (e.g. ~/.caveman/exports/<trial-id>) when empty is legitimate
- Ensure any dir-derivation helper propagates its error instead of returning ""
Example fix
// before
files, err := st.ExportTrial(plan, exportDir) // exportDir == ""
// after
if exportDir == "" {
exportDir = filepath.Join(home, "exports", plan.ID)
}
files, err := st.ExportTrial(plan, exportDir) Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(outDir) == "" {
outDir = filepath.Join(home, "exports", plan.ID) // or reject at CLI
} Type guard
func hasExportDir(p string) bool { return strings.TrimSpace(p) != "" } Try / catch
files, err := st.ExportTrial(plan, outDir)
if err != nil && strings.Contains(err.Error(), "export directory is required") {
return usageError("--dir is required for trial export")
} Prevention
- Require the export-dir flag or give it a documented default under home
- Abort the export flow when a folder-picking step is cancelled instead of continuing with ""
- Check the directory is on a writable local filesystem before export
When it happens
Trigger: Calling ExportTrial(plan, "") — e.g. the export directory flag was optional, unset, or a preceding directory-selection step failed silently and passed its empty result.
Common situations: Shell/CLI wiring where the dir argument is optional with no default; a GUI/script flow in which the user cancelled the folder picker and the code continued with ""; refactors that dropped the argument.
Related errors
- report path is required
- cache-replay: -trace and positive request/token/trace/respon
- cacheengine: no stable prefix
- cacheengine: invalid scope
- cacheengine: invalid epoch
AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15).
Data as JSON: /api/errors/dd6725c0eca20f5d.
Report an issue: GitHub.