{"record":{"id":"8e840a339c6aa5ec","repo":"JuliusBrussee/caveman","slug":"cachebench-no-trace-records","errorCode":null,"errorMessage":"cachebench: no trace records","messagePattern":"cachebench: no trace records","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/trace.go","lineNumber":342,"sourceCode":"\t\tif record.Schema == TraceSchema || record.Schema == TraceSchemaV2 {\n\t\t\tif record.ExpectedRPM <= 0 || record.ExpectedCalls <= 0 || !validTimingBasis(record.TimingBasis) {\n\t\t\t\treturn nil, fmt.Errorf(\"cachebench: trace line %d: incomplete replay metadata\", line)\n\t\t\t}\n\t\t}\n\t\tif record.Schema == TraceSchema {\n\t\t\tif record.DeclaredInputTokens <= 0 || record.DeclaredInputTokens < record.PrefixTokens || record.MaxOutputTokens <= 0 || !requestBudgetMatchesBody(record) {\n\t\t\t\treturn nil, fmt.Errorf(\"cachebench: trace line %d: incomplete or mismatched billed-token budget\", line)\n\t\t\t}\n\t\t}\n\t\tseen[record.RequestID] = true\n\t\trecord.Body = append(json.RawMessage(nil), record.Body...)\n\t\trecords = append(records, record)\n\t}\n\tif err := scanner.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"cachebench: read trace: %w\", err)\n\t}\n\tif len(records) == 0 {\n\t\treturn nil, errors.New(\"cachebench: no trace records\")\n\t}\n\treturn records, nil\n}\n\n// NativeRequest reconstructs exact optimizer input captured by v2 or v3 trace.\n// Legacy v1 traces remain readable for observation joins, but cannot drive live\n// replay because they omitted routing and economics inputs.\nfunc (record TraceRecord) NativeRequest() (cacheengine.NativeRequest, error) {\n\tif record.Schema != TraceSchema && record.Schema != TraceSchemaV2 {\n\t\treturn cacheengine.NativeRequest{}, fmt.Errorf(\"cachebench: request %q needs %s or %s for reconstruction\", record.RequestID, TraceSchemaV2, TraceSchema)\n\t}\n\tif !validTraceIdentity(record) || !validTimingBasis(record.TimingBasis) || record.ExpectedRPM <= 0 || record.ExpectedCalls <= 0 || record.PrefixTokens < 0 || !validUniqueJSONObject(record.Body) || record.BodySHA256 != bodyDigest(record.Body) || record.StableSegmentCount < 0 || record.StableSegmentCount > len(record.Prefix) || !validPrefix(record.Prefix) {\n\t\treturn cacheengine.NativeRequest{}, fmt.Errorf(\"cachebench: request %q has incomplete or invalid replay identity\", record.RequestID)\n\t}\n\treturn cacheengine.NativeRequest{\n\t\tScope: record.Scope, Epoch: record.Epoch, PartitionKey: record.PartitionKey,\n\t\tExpectedRequestsPerMinute: record.ExpectedRPM, ExpectedCalls: record.ExpectedCalls,\n\t\tProvider: record.Provider, Model: record.Model, Region: record.Region, Endpoint: record.Endpoint,","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/trace.go#L324-L360","documentation":"The trace JSONL reader reached EOF (or read only blank input) without accepting any records. A replay needs at least one valid trace record, so an empty stream — wrong file, empty file, or over-aggressive filtering — fails here.","triggerScenarios":"Thrown at cacheengine/cachebench/trace.go:342 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the -trace path points to a non-empty JSONL file containing valid records","Check that earlier reading of the same stream did not exhaust it before passing the reader"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}