{"record":{"id":"270d4312d037814f","repo":"JuliusBrussee/caveman","slug":"cachebench-observation-d-empty-or-duplicate-requ","errorCode":null,"errorMessage":"cachebench: observation %d empty or duplicate request_id","messagePattern":"cachebench: observation (.+?) empty or duplicate request_id","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/observed.go","lineNumber":200,"sourceCode":"\t\treport.Status = \"pass\"\n\t}\n\treport.EvidenceLimitations = []string{\n\t\t\"population completeness is not proven unless EvaluateObservedAgainstTrace is used\",\n\t\t\"provider counters prove reads and writes only for supplied records; evaluator binds but does not inspect retained response artifacts\",\n\t\t\"quality_passed is supplied by external task verifier; evaluator binds but does not inspect retained grader artifacts\",\n\t\t\"report does not prove omitted requests, tail completeness, production prevalence, invoice spend, or verified savings\",\n\t}\n\treturn report, nil\n}\n\nfunc validateObservationRecords(records []ObservationRecord) error {\n\tseen := make(map[string]bool, len(records))\n\tfor index, record := range records {\n\t\tif record.Schema != ObservationSchema && record.Schema != ObservationSchemaV2 {\n\t\t\treturn fmt.Errorf(\"cachebench: observation %d schema %q\", index, record.Schema)\n\t\t}\n\t\tif !validBoundedText(record.RequestID, 512, false) || seen[record.RequestID] {\n\t\t\treturn fmt.Errorf(\"cachebench: observation %d empty or duplicate request_id\", index)\n\t\t}\n\t\tseen[record.RequestID] = true\n\t\tif !validBoundedText(record.Provider, 64, false) || !validBoundedText(record.Epoch, 1024, false) || !validBoundedText(record.QualityVerifier, 256, false) || !validBoundedText(record.ProfileID, 256, true) || !validBoundedText(record.EngineReason, 1024, true) || !validEvidenceSHA256(record.ProviderEvidenceSHA256) || !validEvidenceSHA256(record.QualityEvidenceSHA256) {\n\t\t\treturn fmt.Errorf(\"cachebench: observation %d missing provider or quality evidence provenance\", index)\n\t\t}\n\t\tif record.RequestBodySHA256 != \"\" && !validSHA256(record.RequestBodySHA256) {\n\t\t\treturn fmt.Errorf(\"cachebench: observation %d has invalid request body digest\", index)\n\t\t}\n\t\toptimizerIDs := map[string]bool{}\n\t\tfor _, optimizerID := range record.OptimizerIDs {\n\t\t\tif !validBoundedText(optimizerID, 256, false) || optimizerIDs[optimizerID] {\n\t\t\t\treturn fmt.Errorf(\"cachebench: observation %d has invalid optimizer identity\", index)\n\t\t\t}\n\t\t\toptimizerIDs[optimizerID] = true\n\t\t}\n\t}\n\treturn nil\n}","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/observed.go#L182-L218","documentation":"validateObservationRecords walks the in-memory observation list and rejects record %d whose request_id is empty or duplicates an earlier one. Used as a shared preflight by evaluation, reading, and replay-result validation paths.","triggerScenarios":"Thrown at cacheengine/cachebench/observed.go:200 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Deduplicate observation records by request_id","Ensure every captured request carries an id"],"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"}