Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON output invalid due to errors on stdout #791

Closed
jorhett opened this issue Nov 17, 2020 · 2 comments · Fixed by #799
Closed

JSON output invalid due to errors on stdout #791

jorhett opened this issue Nov 17, 2020 · 2 comments · Fixed by #799
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jorhett
Copy link

jorhett commented Nov 17, 2020

Describe the bug

JSON output is invalid due to errors on stdout.

To Reproduce

Steps to reproduce the behavior:

  1. Without being authenticated, run boundary auth-methods list -format=json 2> /dev/null
  2. First line of output is not valid JSON
No saved credential found, continuing without
[{"id":"ampw_foobar","scope_id":"global","scope":{"id": ...

Expected behavior

Valid JSON that could be used by a program, like jq to get the auth method id:

    boundary auth-methods list -format=json |  jq -r '.[] | select(.type=="password").id'

Additional context
Add any other context about the problem here.

This is the required workaround, which is messy:

    boundary auth-methods list -format=json |grep -v 'No saved credential' | jq '.[]'
@jefferai
Copy link
Member

This is kind of a tricky one.

We assume that you will want to load a saved token since this would be normal behavior, and that if you don't want to, that you would disable it via -keyring-type none. So arguably this is an error and we should switch it to stderr.

On the other hand, if you aren't expecting a saved token to be available, but have not actually disabled it, then this is useful information but not actually an error, and it's easy to work around by simply telling the CLI not to try to look for a saved token.

So this is really about user expectation. That said, I'm in favor of switching this to stderr, because it will help with output redirection cases and it can still be disabled via setting the keyring type.

@jefferai jefferai added this to the 0.1.3 milestone Nov 20, 2020
@jorhett
Copy link
Author

jorhett commented Nov 20, 2020

and it's easy to work around by simply telling the CLI not to try to look for a saved token

Just FYI we're putting this in people's shell profiles to simplify logging in... which is before they know what boundary is, nevermind have made a choice about keyring ;-)

export BOUNDARY_AUTH_METHOD_ID=$(\
  boundary auth-methods list -scope-id=global -format=json \
  |  jq -r '.[] | select(.type=="password").id' )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants