{"record":{"id":"4a2108fc76b186b5","repo":"JuliusBrussee/caveman","slug":"trial-id-is-required","errorCode":null,"errorMessage":"trial_id is required","messagePattern":"trial_id is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/internal/store/trial_store.go","lineNumber":61,"sourceCode":"func (s *Store) RecordPayload(label, requestID, traceID string, body []byte) {\n\ttrialID := strings.TrimPrefix(label, \"trial:\")\n\tif trialID == \"\" || trialID == label {\n\t\treturn\n\t}\n\t_, err := s.db.Exec(\n\t\t`INSERT OR IGNORE INTO trial_payloads\n\t\t  (trial_id, request_id, trace_id, ts, request_bytes, raw_request)\n\t\t  VALUES (?, ?, ?, ?, ?, ?)`,\n\t\ttrialID, requestID, traceID, time.Now().UTC().Format(time.RFC3339), len(body), append([]byte(nil), body...),\n\t)\n\tif err != nil && s.logger != nil {\n\t\ts.logger.Warn(\"local trial payload insert failed\", \"error\", err, \"request_id\", requestID)\n\t}\n}\n\nfunc (s *Store) StartTrial(trialID, agentSlug, command string) error {\n\tif trialID == \"\" {\n\t\treturn fmt.Errorf(\"trial_id is required\")\n\t}\n\t_, err := s.db.Exec(\n\t\t`INSERT INTO trial_runs (trial_id, agent_slug, command, started_at)\n\t\t  VALUES (?, ?, ?, ?)\n\t\t  ON CONFLICT(trial_id) DO UPDATE SET\n\t\t    agent_slug = excluded.agent_slug,\n\t\t    command = excluded.command`,\n\t\ttrialID, agentSlug, command, time.Now().UTC().Format(time.RFC3339),\n\t)\n\treturn err\n}\n\nfunc (s *Store) FinishTrial(trialID string, exitCode int) error {\n\tif trialID == \"\" {\n\t\treturn fmt.Errorf(\"trial_id is required\")\n\t}\n\t_, err := s.db.Exec(\n\t\t`UPDATE trial_runs SET ended_at = ?, exit_code = ? WHERE trial_id = ?`,","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/internal/store/trial_store.go#L43-L79","documentation":"StartTrial records the start of a trial run keyed by trial_id; an empty trial_id is rejected outright since every trial row is identified by it. The insert upserts agent_slug and command for the given trial.","triggerScenarios":"Calling Store.StartTrial(\"\", agentSlug, command) — the trial ID argument was empty or a variable that failed to be populated before the call.","commonSituations":"The CLI wrapper (runTrial) did not receive --trial-id, or the caller generated the ID conditionally and the branch producing it was skipped.","solutions":["Generate or pass a non-empty trial ID before calling StartTrial (e.g. UUID or slug).","In the CLI path, require the trial-id flag and fail with a clear usage message if absent.","Add a caller-side guard: if trialID == \"\" { return errors.New(\"trial id required\") }.","If the ID derives from another value, check why that source was empty."],"exampleFix":"// before\nerr := store.StartTrial(trialID, agentSlug, cmd) // trialID may be \"\"\n// after\nif trialID == \"\" { trialID = uuid.NewString() }\nerr := store.StartTrial(trialID, agentSlug, cmd)","handlingStrategy":"validation","validationCode":"if trialID == \"\" {\n    return errors.New(\"--trial-id is required to start a trial\")\n}","typeGuard":null,"tryCatchPattern":"if err := store.StartTrial(trialID, slug, cmd); err != nil {\n    if err.Error() == \"trial_id is required\" {\n        return fmt.Errorf(\"generate a trial id before starting the trial\")\n    }\n    return err\n}","preventionTips":["Generate a UUID/slug trial ID at entry point if not supplied.","Make --trial-id a required flag in the trial command.","Assert trialID != \"\" in tests around StartTrial."],"tags":["validation","trial","required-argument"],"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"}