{"record":{"id":"b53ab24d852cc860","repo":"JuliusBrussee/caveman","slug":"cachebench-trace-line-d-incomplete-or-mismatche","errorCode":null,"errorMessage":"cachebench: trace line %d: incomplete or mismatched billed-token budget","messagePattern":"cachebench: trace line (.+?): incomplete or mismatched billed-token budget","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/trace.go","lineNumber":331,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"cachebench: trace line %d: invalid schema or request_id\", line)\n\t\t}\n\t\tif _, err := time.Parse(time.RFC3339Nano, record.At); err != nil || !validTraceIdentity(record) || record.PrefixTokens < 0 {\n\t\t\treturn nil, fmt.Errorf(\"cachebench: trace line %d: incomplete request identity\", line)\n\t\t}\n\t\tif len(record.Body) > limits.MaxBodyBytes || !json.Valid(record.Body) || record.BodySHA256 == \"\" || record.BodySHA256 != bodyDigest(record.Body) {\n\t\t\treturn nil, fmt.Errorf(\"cachebench: trace line %d: invalid body or digest\", line)\n\t\t}\n\t\tif record.StableSegmentCount < 0 || record.StableSegmentCount > len(record.Prefix) || !validPrefix(record.Prefix) {\n\t\t\treturn nil, fmt.Errorf(\"cachebench: trace line %d: invalid prefix\", line)\n\t\t}\n\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.","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/cacheengine/cachebench/trace.go#L313-L349","documentation":"Error \"cachebench: trace line %d: incomplete or mismatched billed-token budget\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at cacheengine/cachebench/trace.go:331 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the billed-token budget on the trace line."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}