flyctl secrets import munges quotes

I ran into an issue where

$ flyctl secrets set FOO="bar"

will set the value of FOO to be bar without quotes, while

$ cat .env
FOO="bar"

$ flyctl secrets import < file

will set the value of FOO to be "bar" with quotes.

I know this is because bash is eating the quotes for me when I have them in the command and flyctl never sees them, but this does break my expectation that flyctl secrets import acts the same way as sourcing a .env file.

There’s some handling of triple quoted strings in the secrets import code, my suggestion is to also handle single quotes similarly.

I’m not sure this is something flyctl can do, as the quotes are actually consumed by bash, so they don’t even get to flyctl:

$ echo FOO="bar"
FOO=bar
$ echo 'FOO="bar"'
FOO="bar"

Yup!

My suggestion was to filter out quotes when doing import from a file / STDIN to mimic this behavior and keep things consistent

Ugh, a classic case of replying before actually reading the whole thing, sorry! :roll_eyes:

1 Like

This is a good idea, and probably a quick fix if any of can figure out how to unescape bash values. It would make sense for FOO="bar\"baz" to do the right thing too.