JuliusBrussee/caveman · error
export directory is required
Error message
export directory is required
What it means
ExportTrial writes the trial plan as JSON plus related artifacts into outDir. An empty outDir is rejected with 'export directory is required' before any directory is created, preventing writes to unintended locations. It is the directory-level analogue of the report-path guards.
Solutions
- Supply the export directory argument to the trial command
- Set the environment variable or config field that carries outDir
- Add a caller-side check that fails with a clear message when the directory is blank
Example fix
// before
store.ExportTrial(plan, os.Getenv("TRIAL_EXPORT_DIR"))
// after
dir := os.Getenv("TRIAL_EXPORT_DIR")
if dir == "" {
return fmt.Errorf("TRIAL_EXPORT_DIR must point at an export directory")
}
store.ExportTrial(plan, dir) Defensive patterns
Strategy: validation
Validate before calling
if outDir == "" { return fmt.Errorf("trial export directory is required") }
if info, err := os.Stat(outDir); err == nil && !info.IsDir() { return fmt.Errorf("%s is not a directory", outDir) } Prevention
- Set a default export directory in your automation
- Fail fast when the export-dir env var is unset or empty
- Validate the target is a directory (or creatable) before exporting
- Document the export-dir flag as mandatory in usage text
When it happens
Trigger: Calling ExportTrial (directly or via runTrial) with an empty outDir, e.g. when the export directory flag/env var was not provided.
Common situations: Automation omitting the export-dir flag for a trial run; an unset EXPORT_DIR env var; a wrapper script that strips empty arguments.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- at least one report path and the canonical span fixture…
- at least one sink id is required
- base and head must be full Git object IDs
- cave_live_eval_sandbox_profile_invalid
- caveman agent: entry must export default agent()
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/dd6725c0eca20f5d.
Report an issue: GitHub.
Appendix: 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 3ee70a1026)