{"record":{"id":"d0bdbca9246e3038","repo":"JuliusBrussee/caveman","slug":"cachebench-replay-request-q-has-empty-provider","errorCode":null,"errorMessage":"cachebench: replay request %q has empty provider","messagePattern":"cachebench: replay request %q has empty provider","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/replay.go","lineNumber":451,"sourceCode":"\t\tInputBudgetClaimedProviderCounted: len(tokenBases) == 1 && tokenBases[0] == TokenProviderCounted,\n\t\tMaxConcurrency:                    limits.MaxConcurrency,\n\t}, nil\n}\n\n// ValidateReplayTarget rejects a live population that cannot meet its minimum\n// sample gate even if every captured request proves cache eligible.\nfunc ValidateReplayTarget(records []TraceRecord, target Target) error {\n\tif err := validateTarget(target); err != nil {\n\t\treturn err\n\t}\n\tif len(records) == 0 {\n\t\treturn errors.New(\"cachebench: replay trace is empty\")\n\t}\n\tcounts := map[string]int{}\n\tfor _, record := range records {\n\t\tprovider := strings.ToLower(strings.TrimSpace(record.Provider))\n\t\tif provider == \"\" {\n\t\t\treturn fmt.Errorf(\"cachebench: replay request %q has empty provider\", record.RequestID)\n\t\t}\n\t\tcounts[provider]++\n\t}\n\tfor provider, count := range counts {\n\t\tif count < target.MinEligibleRequest {\n\t\t\treturn fmt.Errorf(\"cachebench: provider %q population %d cannot meet minimum eligible requests %d\", provider, count, target.MinEligibleRequest)\n\t\t}\n\t}\n\treturn nil\n}\n\n// Run validates full population, prepares equivalent bodies, then dispatches replay.\nfunc (runner ReplayRunner) Run(ctx context.Context, records []TraceRecord, emit func(ReplayResult) error) error {\n\tif runner.Engine == nil || runner.Transport == nil || runner.Verifier == nil || emit == nil {\n\t\treturn errors.New(\"cachebench: replay engine, transport, verifier, and emitter required\")\n\t}\n\tif _, err := ValidateReplay(records, runner.Limits, runner.TimeScale); err != nil {\n\t\treturn err","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/cacheengine/cachebench/replay.go#L433-L469","documentation":"ValidateReplayTarget rejected a trace record whose Provider field, after strings.TrimSpace and ToLower, is empty. The replay harness groups requests by provider to enforce per-provider minimum eligible request counts, so a providerless record cannot be attributed to any population. The error is thrown before any request is sent.","triggerScenarios":"Calling ValidateReplayTarget (or Run, which validates the population) with a TraceRecord whose Provider is \"\", \" \", or only whitespace. Records produced by a trace capture step that forgot to copy the provider field, or hand-written JSON traces missing the provider key, trigger it on the first offending record.","commonSituations":"Importing traces from another tool that names the field differently (vendor vs provider); a JSON trace edited by hand with a typo'd key; a capture bug where the provider column is dropped for one row of many.","solutions":["Inspect the RequestID named in the message and fix that record's Provider field (e.g. \"openai\", \"anthropic\") in the trace source.","If generating traces programmatically, assert record.Provider != \"\" at capture time so bad rows fail at capture, not replay.","Sanitize the trace before validation: filter or reject records with strings.TrimSpace(record.Provider) == \"\".","If the provider genuinely cannot be determined, drop the record and re-check that remaining populations still meet MinEligibleRequest (error 881 will otherwise fire)."],"exampleFix":"// before\nrecords = append(records, TraceRecord{RequestID: \"req-42\", At: at, Body: body}) // Provider never set\n\n// after\nrecords = append(records, TraceRecord{RequestID: \"req-42\", Provider: \"openai\", At: at, Body: body})","handlingStrategy":"validation","validationCode":"func hasProvider(r cachebench.TraceRecord) bool {\n    return strings.ToLower(strings.TrimSpace(r.Provider)) != \"\"\n}\n\nfor _, r := range records {\n    if !hasProvider(r) {\n        return fmt.Errorf(\"record %s lacks provider\", r.RequestID)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate trace records at capture time: reject rows with empty/whitespace Provider.","Run a lint step over JSON traces (schema check with required provider field) before replay.","Group records by normalized provider up front and assert every group is non-empty."],"tags":["cachebench","validation","trace-data","replay"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}