MatrixAI / Polykey-CLI

Polykey CLI - Open Source Decentralized Secret Sharing System for Zero Trust Workflows
https://polykey.com
GNU General Public License v3.0
6 stars 3 forks source link

`secrets write` doesn't gracefully handle writing to a directory #311

Open aryanjassal opened 1 week ago

aryanjassal commented 1 week ago

Describe the bug

When writing to a directory, the command should provide appropriate feedback bail out. This should either be done immediately (by preemptively checking if the target is a valid file path or not), or later, by raising an appropriate error.

Currently, it just returns this output, which is not really explicit or apparent in what went wrong:

[aryanj@matrix-34xx:~]$ pk secrets write vault:dir
writing to dir <Ctrl-D>
undefined

[aryanj@matrix-34xx:~]$ echo $?
255

To Reproduce

  1. Try writing to a directory using stdin
  2. Observe issue

Expected behavior

As in secrets cat, an error could be raised:

[aryanj@matrix-34xx:~]$ pk secrets cat vault:dir     
ErrorSecretsIsDirectory: dir: Is a directory

Screenshots

Platform

Additional context

Notify maintainers

@aryanjassal

linear[bot] commented 1 week ago

ENG-434 `secrets write` doesn't gracefully handle writing to a directory

aryanjassal commented 1 day ago

A similar behaviour is seen when trying to remove the vault root using secrets rm. It just prints undefined and fails. Doing this should yield a proper error message.