From 201fbed78ccbb1714b1436a880a8689ef9af5342 Mon Sep 17 00:00:00 2001 From: David Snelling Date: Wed, 12 Nov 2025 16:01:25 -0800 Subject: [PATCH] fix: unwrap binary data in COW adapter to fix blob integrity check (v5.7.5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CRITICAL BUG FIX #2 - VFS "Blob integrity check failed" errors Root cause (Workshop team finding): COWStorageAdapter wraps binary data in JSON {_binary: true, data: "base64..."} but doesn't unwrap on read, causing hash mismatch. Timeline: - WRITE: BlobStorage hashes original content → stored hash - Storage adapter wraps in JSON before saving - READ: Adapter returns JSON wrapper as Buffer - BlobStorage hashes JSON wrapper → different hash → ERROR Fix (baseStorage.ts:332-336): - Detect {_binary: true, data: "..."} objects - Unwrap and decode base64 back to original Buffer - BlobStorage now hashes same data on read and write This completes v5.7.5 with TWO critical VFS fixes: 1. Compression race condition (BlobStorage async init) 2. JSON wrapper hash mismatch (COW adapter unwrapping) Credit: Workshop team for forensic analysis of blob corruption 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/storage/baseStorage.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/storage/baseStorage.ts b/src/storage/baseStorage.ts index 2efc3780..3557d302 100644 --- a/src/storage/baseStorage.ts +++ b/src/storage/baseStorage.ts @@ -329,6 +329,11 @@ export abstract class BaseStorage extends BaseStorageAdapter { if (Buffer.isBuffer(data)) { return data } + // v5.7.5: Unwrap binary data stored as {_binary: true, data: "base64..."} + // Fixes "Blob integrity check failed" - hash must be calculated on original content + if (data._binary && typeof data.data === 'string') { + return Buffer.from(data.data, 'base64') + } return Buffer.from(JSON.stringify(data)) } catch (error) { return undefined