cli icon indicating copy to clipboard operation
cli copied to clipboard

Error: Unknown cipher type

Open SirRippovMaple opened this issue 5 years ago • 1 comments

Describe the Bug

When trying to create a secure note using the Bitwarden CLI, the creation fails with an error message indicating that a cipher is unknown.

Steps To Reproduce

The following command reproduces the issue on my machine:

bw get template item.securenote | jq '.name="ca.key"' | jq ".notes=\"$(cat ca.key)\"" | bw encode | bw create item

The cat subcommand is unnecessary, and the following command will also reproduce the same error:

bw get template item.securenote | jq '.name="ca.key"' | jq ".notes=\"foo\"" | bw encode | bw create item

Expected Result

I expect the secure note to be created with the contents of my ca.key file as the contents of the note. (Or "foo" if you are running the simplified command.)

Actual Result

(node:46672) UnhandledPromiseRejectionWarning: Error: Unknown cipher type.
    at cipher_service_CipherService.<anonymous> (/snapshot/cli-1.18.0/build/bw.js:4893:27)
    at Generator.next (<anonymous>)
    at /snapshot/cli-1.18.0/build/bw.js:3864:71
    at new Promise (<anonymous>)
    at /snapshot/cli-1.18.0/build/bw.js:3860:12
    at cipher_service_CipherService.encryptCipherData (/snapshot/cli-1.18.0/build/bw.js:4831:16)
    at cipher_service_CipherService.<anonymous> (/snapshot/cli-1.18.0/build/bw.js:3998:22)
    at Generator.next (<anonymous>)
    at /snapshot/cli-1.18.0/build/bw.js:3864:71
    at new Promise (<anonymous>)
(Use `bw --trace-warnings ...` to show where the warning was created)
(node:46672) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:46672) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Environment

  • Operating system: Manjaro Linux x86_64, kernel 5.10.61-1-MANJARO
  • Shell: zsh
  • Build Version (run bw --version): 1.18.0

Additional Context

I found this previous issue and I think that it is related, but I am using bw get template item.securenote, so that issue's resolution does not apply here.

SirRippovMaple avatar Sep 04 '21 16:09 SirRippovMaple

I've modified the command after reading a crucial bit of documentation. Here is the fixed command:

bw get template item | jq ".secureNote=$(bw get template item.securenote)" | jq '.name="ca.key"' | jq ".notes=\"$(cat ca.key)\"" | jq .type=2 | bw encode | bw create item

I'll close this issue because my problem is solved.

SirRippovMaple avatar Sep 04 '21 16:09 SirRippovMaple