{"record":{"id":"678faf361191f663","repo":"JuliusBrussee/caveman","slug":"cachebench-observation-population-d-does-not-mat","errorCode":null,"errorMessage":"cachebench: observation population %d does not match trace population %d","messagePattern":"cachebench: observation population (.+?) does not match trace population (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/observed.go","lineNumber":38,"sourceCode":"\treturn ObservationRecord{\n\t\tSchema: ObservationSchema, RequestID: requestID, RequestBodySHA256: bodyDigest(originalRequestBody),\n\t\tProviderEvidenceSHA256: bodyDigest(providerEvidence),\n\t\tProvider:               provider, Epoch: epoch,\n\t\tEligibleInputTokens: eligibleInputTokens, CacheEligible: cacheEligible, Applied: result.Applied,\n\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 {","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/observed.go#L20-L56","documentation":"EvaluateObservedAgainstTrace requires a one-to-one join between observation records and trace records; the two slices differ in length, so some observed requests have no trace counterpart (or vice versa) and the evaluation cannot proceed.","triggerScenarios":"Thrown at cacheengine/cachebench/observed.go:38 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate the observation set from the exact trace being evaluated","Check for dropped or duplicated records in either JSONL before joining"],"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"}