{"record":{"id":"1efa9da1e1a5f69c","repo":"JuliusBrussee/caveman","slug":"cachebench-trace-request-d-has-invalid-schema-or","errorCode":null,"errorMessage":"cachebench: trace request %d has invalid schema or request_id","messagePattern":"cachebench: trace request (.+?) has invalid schema or request_id","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/observed.go","lineNumber":43,"sourceCode":"\t\tEngineDecision: result.Decision, EngineReason: result.Reason, ProfileID: result.Profile.ID,\n\t\tAttribution: result.Profile.Attribution, OptimizerIDs: append([]string(nil), result.OptimizerIDs...),\n\t\tQualityPassed: verification.Passed, QualityVerifier: verification.Verifier,\n\t\tQualityEvidenceSHA256: bodyDigest(verification.Evidence), Usage: append(json.RawMessage(nil), rawUsage...),\n\t}\n}\n\n// EvaluateObservedAgainstTrace requires exact request population and body joins.\nfunc EvaluateObservedAgainstTrace(records []ObservationRecord, trace []TraceRecord, target Target) (Report, error) {\n\tif err := validateObservationRecords(records); err != nil {\n\t\treturn Report{}, err\n\t}\n\tif len(records) != len(trace) {\n\t\treturn Report{}, fmt.Errorf(\"cachebench: observation population %d does not match trace population %d\", len(records), len(trace))\n\t}\n\tbyID := make(map[string]TraceRecord, len(trace))\n\tfor index, request := range trace {\n\t\tif request.Schema != TraceSchema && request.Schema != TraceSchemaV2 || strings.TrimSpace(request.RequestID) == \"\" {\n\t\t\treturn Report{}, fmt.Errorf(\"cachebench: trace request %d has invalid schema or request_id\", index)\n\t\t}\n\t\tif _, exists := byID[request.RequestID]; exists {\n\t\t\treturn Report{}, fmt.Errorf(\"cachebench: duplicate trace request %q\", request.RequestID)\n\t\t}\n\t\tif strings.TrimSpace(request.Provider) == \"\" || strings.TrimSpace(request.Epoch) == \"\" || !validUniqueJSONObject(request.Body) || request.BodySHA256 == \"\" || request.BodySHA256 != bodyDigest(request.Body) {\n\t\t\treturn Report{}, fmt.Errorf(\"cachebench: trace request %q has invalid identity, body, or digest\", request.RequestID)\n\t\t}\n\t\tif request.StableSegmentCount < 0 || request.StableSegmentCount > len(request.Prefix) || !validPrefix(request.Prefix) {\n\t\t\treturn Report{}, fmt.Errorf(\"cachebench: trace request %q has invalid prefix\", request.RequestID)\n\t\t}\n\t\tbyID[request.RequestID] = request\n\t}\n\tfor _, record := range records {\n\t\trequest, exists := byID[record.RequestID]\n\t\tif !exists {\n\t\t\treturn Report{}, fmt.Errorf(\"cachebench: observation request %q absent from trace\", record.RequestID)\n\t\t}\n\t\tif record.Provider != request.Provider || record.Epoch != request.Epoch {","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/observed.go#L25-L61","documentation":"Validation guard in EvaluateObservedAgainstTrace: a trace entry has a schema other than TraceSchema/TraceSchemaV2 or an empty request_id. The trace record at the interpolated index is the input at fault.","triggerScenarios":"Thrown at cacheengine/cachebench/observed.go:43 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate the trace with the current writer so schema stamps are correct","Fill in a unique non-empty request_id per record"],"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"}