Gotcha with `Update available` announcements when using `--json`

The Update available announcement breaks JSON output.

For example:

flyctl ips list \
--app=${APP} --json \
| jq -r '.[]|select(.Type=="v4").Address'
parse error: Invalid numeric literal at line 1, column 2
                                                        write /dev/stdout: broken pipe

NOTE the acceptable but curious spacing in the output. I get this with e.g. flyctl apps list --json | jq . too. In that case, it’s still valid JSON, just unexpectedly, extensively padded.

This is because:

flyctl ips list \
--app=${APP} \
--json
Update available 0.0.207 -> 0.0.209
Update with flyctl version update

[
    {
        "ID": "...",
        "Address": "213.188....",
        "Type": "v4",
        "CreatedAt": "2021-04-13T15:51:55Z"
    },
    {
        "ID": "...",
        "Address": "2a09:8280:1:...",
        "Type": "v6",
        "CreatedAt": "2021-04-13T15:51:55Z"
    }
]

The --json flag is not being respected && the command’s output is not JSON.

Yes, I need to update but… :slight_smile:

1 Like

Good catch, that message should be going to stderr which wouldn’t get piped. We’ll take a look.

1 Like

As an aside, I’m always advocating to not use latest but ignored my own advice and was using flyctl[:latest] and, of course, didn’t get bumped to the actual latest.

It may be worth considering dropping the latest tag from dockerhub so we all avoid that trap.

This continues to be an issue.

I have deployment (bash) scripts (don’t hate me :-)) that break when --json!=JSON

I think I figured out the crux of the issue - dropped a comment on GitHub, but making note here about “tty” option with docker/podman/container usage being the core of the issue in this case - in case anyone else stumbles into it!

1 Like

Awesome! Thank you.