{"record":{"id":"b8fa3ccb2ef22ce7","repo":"JuliusBrussee/caveman","slug":"probe-bytes-did-not-round-trip","errorCode":null,"errorMessage":"probe bytes did not round-trip","messagePattern":"probe bytes did not round-trip","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"shared/platform/objectstore/objectstore.go","lineNumber":255,"sourceCode":"\tkey := \"_cave_health/\" + base64.RawURLEncoding.EncodeToString(probe)\n\tif err := store.Put(ctx, key, probe, \"application/octet-stream\"); err != nil {\n\t\treturn err\n\t}\n\tcleaned := false\n\tdefer func() {\n\t\tif !cleaned {\n\t\t\t// Keep health checks within their caller deadline. A failed probe may\n\t\t\t// leave one random, tenant-free canary for lifecycle cleanup; readiness\n\t\t\t// must never hang on an unbounded background delete.\n\t\t\t_ = PurgeObject(ctx, store, key)\n\t\t}\n\t}()\n\tgot, err := store.Get(ctx, key)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !bytes.Equal(got, probe) {\n\t\treturn errors.New(\"probe bytes did not round-trip\")\n\t}\n\tif err := PurgeObject(ctx, store, key); err != nil {\n\t\treturn err\n\t}\n\tcleaned = true\n\texists, err := store.Exists(ctx, key)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif exists {\n\t\treturn errors.New(\"probe object still exists after purge\")\n\t}\n\treturn nil\n}\n\nfunc (m *minioStore) Put(ctx context.Context, key string, body []byte, contentType string) error {\n\tif contentType == \"\" {\n\t\tcontentType = \"application/octet-stream\"","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/objectstore/objectstore.go#L237-L273","documentation":"Probe writes 32 random bytes under a _cave_health/ key, reads them back, and compares; if the returned bytes differ from what was written it returns 'probe bytes did not round-trip'. This detects backends that claim success on Put/Get but corrupt, truncate, or return stale data — the probe body contains no tenant data and all versions are purged afterwards.","triggerScenarios":"Get returned different bytes than Put wrote (corrupting proxy or disk, truncated body); a caching layer or wrong-bucket routing served stale/different content for the key; a misbehaving mock or in-memory backend aliasing/mutating the slice; the object was overwritten between write and read by another process using the same probe key (astronomically unlikely due to randomness).","commonSituations":"Testing a new MinIO/S3 deployment or proxy with a broken cache layer; a buggy custom Store implementation; hardware/storage corruption discovered during a live contract test (TestLiveMinioContract) or startup health check.","solutions":["Investigate the backend integrity path: check for corrupting proxies, caches, or disk issues between the client and bucket.","If a custom or in-memory Store is under test, fix it to copy returned bytes rather than aliasing the caller's slice.","Re-run the probe to distinguish transient corruption from deterministic misbehavior.","Verify bucket/versioning configuration isn't serving an older object version for the same key.","Check for any other writer that could overwrite keys under the _cave_health/ prefix."],"exampleFix":"// before (custom Store.Get)\nreturn m.data[key], nil // aliases internal slice, caller may see mutated data\n// after\nb := make([]byte, len(m.data[key]))\ncopy(b, m.data[key])\nreturn b, nil","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := objectstore.Probe(ctx, store); err != nil {\n    if strings.Contains(err.Error(), \"did not round-trip\") {\n        return fmt.Errorf(\"backend data integrity failure: %w\", err)\n    }\n    return err\n}","preventionTips":["Run Probe at startup and in live contract tests to catch corruption early","Ensure custom Store implementations copy byte slices instead of aliasing caller data","Audit proxies/caches between client and bucket for mutation or staleness","Keep versioning settings consistent so reads never serve stale versions of probe keys"],"tags":["objectstore","data-integrity","health-check","s3"],"backgroundTag":"checksum-mismatch","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}