{"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/27d5a3981a347890211bb1bf2439e5c821a63bc9/cacheengine/cachebench/observed.go#L25-L61","documentation":"Each trace entry must carry schema exactly TraceSchema or TraceSchemaV2 and a non-blank RequestID; otherwise the trace's identity model is broken and the exact join against observations cannot be trusted. The error reports the offending trace index.","triggerScenarios":"EvaluateObservedAgainstTrace iterates trace records; record i whose Schema is neither accepted constant, or whose RequestID is empty/whitespace, returns this error immediately.","commonSituations":"Hand-built or third-party trace JSONL missing the schema field; renamed schema constants after a version upgrade; blank request_id lines from a buggy exporter.","solutions":["Set each trace record's schema to the tool's current TraceSchema/TraceSchemaV2 value (check the package constants).","Populate a unique non-empty request_id on every trace line.","Regenerate the trace with the current tool version instead of editing it by hand."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func validTraceHeader(requests []TraceRecord) error {\n\tfor i, r := range requests {\n\t\tif (r.Schema != TraceSchema && r.Schema != TraceSchemaV2) || strings.TrimSpace(r.RequestID) == \"\" {\n\t\t\treturn fmt.Errorf(\"trace request %d has invalid schema or request_id\", i)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":"func isTraceSchema(s string) bool { return s == TraceSchema || s == TraceSchemaV2 }","tryCatchPattern":null,"preventionTips":["Always emit the schema field when writing trace records.","Reject blank request_ids at generation time.","Track schema constants per tool version in CI fixtures."],"tags":["go","cachebench","schema","validation"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}