Skip to content

TypeError: Cannot read property 'filter' of undefined #30

@trdarr

Description

@trdarr

I use Homebrew to install Node on OS X 10.10.5, then use npm 3.5.3 to install Vault 0.3.0.

$ brew install node
🍺  /usr/local/Cellar/node/5.4.1_1: 3,135 files, 35.5M
$ which node
/usr/local/bin/node
$ node --version
v5.4.1
$ which npm
/usr/local/bin/npm
$ npm --version
3.5.3
$ npm install -g vault
/usr/local/lib
`-- vault@0.3.0
  +-- posix-argv-parser@0.4.2
  | `-- when@1.3.0
  +-- pw@0.0.4
  +-- ssh-agent@0.2.4
  | +-- ctype@0.5.4
  | `-- posix-getopt@1.1.0
  `-- vault-cipher@0.3.1

When I try to generate a password with my SSH key, I get a TypeError.

$ vault --key github
/usr/local/lib/node_modules/vault/bin/vault:50
      keys = keys.filter(function(k) { return k.type === 'ssh-rsa' });
                 ^

TypeError: Cannot read property 'filter' of undefined
    at /usr/local/lib/node_modules/vault/bin/vault:50:18
    at Socket.<anonymous> (/usr/local/lib/node_modules/vault/node_modules/ssh-agent/lib/ssh_agent_client.js:294:12)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at emitErrorNT (net.js:1255:8)
    at nextTickCallbackWith2Args (node.js:474:9)
    at process._tickCallback (node.js:388:17)

I realize now that this issue is caused by ssh-agent not starting as a result of my having tried to replace OS X’s built-in ssh-agent with the ssh-agent from Homebrew-installed OpenSSH—other people have had similar problems (Homebrew/homebrew-dupes#242).

While trying to reproduce this issue to submit it, I encountered a similar exception caused by a ~/.vault file left behind by a previous installation: when I tried to generate a password without the --key option, I got a TypeError.

$ vault github
/usr/local/lib/node_modules/vault/bin/vault:76
      var key = keys.filter(function(k) { return k.ssh_key === sshKey })[0];
                    ^

TypeError: Cannot read property 'filter' of undefined
    at /usr/local/lib/node_modules/vault/bin/vault:76:21
    at identitiesAnswer (/usr/local/lib/node_modules/vault/node_modules/ssh-agent/lib/ssh_agent_client.js:179:12)
    at Socket.<anonymous> (/usr/local/lib/node_modules/vault/node_modules/ssh-agent/lib/ssh_agent_client.js:280:12)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:146:16)
    at Socket.Readable.push (_stream_readable.js:110:10)
    at Pipe.onread (net.js:523:20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions