TritonDataCenter / node-manta

Node.js SDK for Manta
75 stars 54 forks source link

mfind of file blows assertion: "ent (object) is required" #288

Closed davepacheco closed 7 years ago

davepacheco commented 8 years ago

Here's an easy way to reproduce it:

dap@sharptooth ~ $ echo -n | mput /dap/public/zero
/dap/public/zero                                                0B                  

dap@sharptooth ~ $ minfo /dap/public/zero
HTTP/1.1 200 OK
etag: 3f1cc837-b19c-c818-dfc2-ef386a7df109
last-modified: Tue, 22 Nov 2016 21:51:45 GMT
access-control-allow-origin: *
durability-level: 0
content-length: 0
content-md5: 1B2M2Y8AsgTpgAmY7PhCfg==
content-type: application/octet-stream
date: Tue, 22 Nov 2016 21:51:49 GMT
server: Manta
x-request-id: 22375304-0b21-426c-b755-f8772f202810
x-response-time: 18
x-server-name: 39adec6c-bded-4a14-9d80-5a8bfc1121f9
connection: keep-alive
x-request-received: 1479851508840
x-request-processing-time: 390

dap@sharptooth ~ $ mfind /dap/public/zero
mfind: AssertionError: ent (object) is required

dap@sharptooth ~ $ DEBUG=1 mfind /dap/public/zero
mfind: AssertionError: ent (object) is required
    at new InvalidDirectoryError (/Users/dap/install/lib/node_modules/manta/lib/client.js:91:12)
    at /Users/dap/install/lib/node_modules/manta/lib/client.js:1039:23
    at self.client.head.onRequestCallback.onResult (/Users/dap/install/lib/node_modules/manta/lib/client.js:1115:21)
    at IncomingMessage.onEnd (/Users/dap/install/lib/node_modules/manta/lib/client.js:468:13)
    at IncomingMessage.g (events.js:180:16)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:944:16
    at process._tickCallback (node.js:458:13)
davepacheco commented 8 years ago

This appears to be fallout from the assert-plus update under #246.

This change causes an "mfind" on an object to work:

$ git diff HEAD
diff --git a/lib/client.js b/lib/client.js
index 4fe45e2..c13be29 100644
--- a/lib/client.js
+++ b/lib/client.js
@@ -88,7 +88,7 @@ function InvalidDirectoryError(dir, ent) {
     Error.call(this);

     assert.string(dir, 'dir');
-    assert.object(ent, 'ent');
+    assert.optionalObject(ent, 'ent');

     this.name = 'InvalidDirectoryError';
     this.message = dir + ' is an invalid manta directory';