Summary
graph.getContent(nodeId) returns Buffer.alloc(0) when the blob OID referenced by CONTENT_PROPERTY_KEY doesn't exist in the git object store. The type signature (Promise<Buffer | null>) and docs suggest it should return null or throw.
Expected behavior
One of:
- Return
null (consistent with the type signature)
- Throw an
Error (consistent with the JSDoc: "Throws generic Error if referenced blob OID not in object store")
Actual behavior
Returns an empty Buffer (length 0), which is truthy and passes null checks silently.
Reproduction
const patch = await graph.createPatch();
patch.addNode('test:node');
await patch.attachContent('test:node', Buffer.from('hello'));
await patch.commit();
// Corrupt the content OID to point at a non-existent blob
const patch2 = await graph.createPatch();
patch2.setProperty('test:node', CONTENT_PROPERTY_KEY, 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef');
await patch2.commit();
const buf = await graph.getContent('test:node');
// Expected: null or thrown error
// Actual: Buffer.alloc(0) — empty buffer, truthy, no error
Impact
Consumers relying on the null check or try/catch to detect missing blobs will silently get empty content. We worked around this in git-mind with a size-mismatch guard (contentBuf.length === 0 && meta.size > 0), but the API contract should handle this at the WARP layer.
Version
git-warp v11.5.0
Summary
graph.getContent(nodeId)returnsBuffer.alloc(0)when the blob OID referenced byCONTENT_PROPERTY_KEYdoesn't exist in the git object store. The type signature (Promise<Buffer | null>) and docs suggest it should returnnullor throw.Expected behavior
One of:
null(consistent with the type signature)Error(consistent with the JSDoc: "Throws generic Error if referenced blob OID not in object store")Actual behavior
Returns an empty
Buffer(length 0), which is truthy and passes null checks silently.Reproduction
Impact
Consumers relying on the null check or try/catch to detect missing blobs will silently get empty content. We worked around this in git-mind with a size-mismatch guard (
contentBuf.length === 0 && meta.size > 0), but the API contract should handle this at the WARP layer.Version
git-warp v11.5.0