{"record":{"id":"ac80adab2fc75e34","repo":"JuliusBrussee/caveman","slug":"no-trial-id-supplied-and-no-trial-runs-exist","errorCode":null,"errorMessage":"no trial_id supplied and no trial runs exist","messagePattern":"no trial_id supplied and no trial runs exist","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/cmd/caveman-proxy/main.go","lineNumber":931,"sourceCode":"\tspend, err := store.Open(dbPath(home), logger)\n\tif err != nil {\n\t\tlogger.Error(\"cannot open local spend store\", \"error\", err)\n\t\tos.Exit(1)\n\t}\n\treturn spend\n}\n\nfunc requiredTrialID(logger *slog.Logger, spend *store.Store, args []string) string {\n\ttrialID := argFlag(args, \"--trial-id\", \"\")\n\tif trialID != \"\" {\n\t\treturn trialID\n\t}\n\tlatest, err := spend.LatestTrialID()\n\tif err != nil {\n\t\tfatalJSON(logger, err)\n\t}\n\tif latest == \"\" {\n\t\tfatalJSON(logger, fmt.Errorf(\"no trial_id supplied and no trial runs exist\"))\n\t}\n\treturn latest\n}\n\nfunc promoteMove(logger *slog.Logger, home, trialID, optimizerID string, plan store.TrialPlan) {\n\tvar move store.TrialMove\n\tfor _, candidate := range plan.Moves {\n\t\tif candidate.OptimizerID == optimizerID {\n\t\t\tmove = candidate\n\t\t\tbreak\n\t\t}\n\t}\n\tif move.OptimizerID == \"\" {\n\t\tfatalJSON(logger, fmt.Errorf(\"optimizer %q not found in trial %s\", optimizerID, trialID))\n\t}\n\tif move.Status != \"safe_now\" || !(strings.HasPrefix(move.SafetyClass, \"S0_\") || strings.HasPrefix(move.SafetyClass, \"S1_\")) {\n\t\tpath := filepath.Join(home, \"reports\", \"caveman-trial-\"+trialID+\"-\"+optimizerID+\"-candidate.yaml\")\n\t\tif err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {","sourceCodeStart":913,"sourceCodeEnd":949,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/cmd/caveman-proxy/main.go#L913-L949","documentation":"This error comes from the caveman-proxy CLI's requiredTrialID helper (proxy/cmd/caveman-proxy/main.go:931). Trial subcommands need a trial_id; if --trial-id is not given, the helper falls back to the most recent trial recorded in the local SQLite spend store. When no --trial-id flag was passed AND the spend store has never recorded any trial run, it exits with this fatal error because there is no sensible default trial to operate on.","triggerScenarios":"Running a trial subcommand (via runTrial, e.g. trial plan/promote/report) without --trial-id on a machine whose ~/.caveman/caveman.db contains zero trial rows — either a fresh install or a database where no trial was ever started.","commonSituations":"Fresh install of caveman-proxy where the user jumps straight to a trial promote/report command; cleared or recreated spend store; typo'd flag name (--trialid vs --trial-id) so the fallback lookup runs and finds nothing; copying commands from docs to a new workstation.","solutions":["Run a trial first (the command that records trial runs) so LatestTrialID() returns a value","Pass the trial explicitly: add --trial-id <id> to the command","Check that ~/.caveman/caveman.db is the store you expect (HOME differences in cron/CI) and contains trial runs","Verify the flag spelling is --trial-id; a misspelled flag makes requiredTrialID fall through to the empty store"],"exampleFix":"// before\ncaveman-proxy trial promote --optimizer my-opt\n// after\ncaveman-proxy trial promote --trial-id 2026-09-20-a --optimizer my-opt","handlingStrategy":"validation","validationCode":"trialID := argFlag(args, \"--trial-id\", \"\")\nif trialID == \"\" {\n    if latest, _ := spend.LatestTrialID(); latest == \"\" {\n        return fmt.Errorf(\"no trial available: run a trial first or pass --trial-id\")\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --trial-id explicitly in scripts/CI instead of relying on the latest-run fallback","Run the trial-recording command before any trial promote/report command","Pin HOME in cron/CI so the correct ~/.caveman/caveman.db is consulted","List existing trial ids first when unsure"],"tags":["cli","missing-argument","trial"],"backgroundTag":"missing-required-argument","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}