JuliusBrussee/caveman · error

cachebench: observation

Error message

cachebench: observation %d has invalid request body digest

What it means

Integrity guard in validateObservationRecords: the record's body does not hash to its recorded bodySHA256 digest, so the body/digest pair has drifted or been tampered with. The record's body or digest field is at fault.

Solutions

  1. Recompute digests at capture time over the exact bytes sent
  2. Avoid re-encoding the body between capture and digest computation
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cacheengine/cachebench/observed.go:207 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18). Data as JSON: /api/errors/c707b79d32f33690. Report an issue: GitHub.

Appendix: source

Thrown at cacheengine/cachebench/observed.go:207

	}
	return report, nil
}

func validateObservationRecords(records []ObservationRecord) error {
	seen := make(map[string]bool, len(records))
	for index, record := range records {
		if record.Schema != ObservationSchema && record.Schema != ObservationSchemaV2 {
			return fmt.Errorf("cachebench: observation %d schema %q", index, record.Schema)
		}
		if !validBoundedText(record.RequestID, 512, false) || seen[record.RequestID] {
			return fmt.Errorf("cachebench: observation %d empty or duplicate request_id", index)
		}
		seen[record.RequestID] = true
		if !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) {
			return fmt.Errorf("cachebench: observation %d missing provider or quality evidence provenance", index)
		}
		if record.RequestBodySHA256 != "" && !validSHA256(record.RequestBodySHA256) {
			return fmt.Errorf("cachebench: observation %d has invalid request body digest", index)
		}
		optimizerIDs := map[string]bool{}
		for _, optimizerID := range record.OptimizerIDs {
			if !validBoundedText(optimizerID, 256, false) || optimizerIDs[optimizerID] {
				return fmt.Errorf("cachebench: observation %d has invalid optimizer identity", index)
			}
			optimizerIDs[optimizerID] = true
		}
	}
	return nil
}

func validSHA256(value string) bool {
	return len(value) == 64 && strings.Trim(value, "0123456789abcdef") == ""
}

func validEvidenceSHA256(value string) bool {
	return validSHA256(value) && value != bodyDigest(nil)

View on GitHub (pinned to 766dce6b13)