Skip to content

stackit auth get-access-token outputs token to stderr instead of stdout #653

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

Closed
rswrz opened this issue Mar 18, 2025 · 2 comments
Closed
Labels
bug Something isn't working has internal tracking issue

Comments

@rswrz
Copy link

rswrz commented Mar 18, 2025

Summary

The stackit auth get-access-token command currently outputs the access token to /dev/stderr instead of /dev/stdout. This behavior breaks standard CLI conventions and complicates usage in scripts and automation.

Current Behavior

  • The access token is written to stderr.

  • Capturing the token in a variable requires redirecting stderr to stdout:

    export STACKIT_SERVICE_ACCOUNT_TOKEN=$(stackit auth get-access-token 2>/dev/stdout)
  • This approach also captures error messages in the variable. Example:

    $ export STACKIT_SERVICE_ACCOUNT_TOKEN=$(stackit auth get-access-token 2>/dev/stdout)
    $ echo $STACKIT_SERVICE_ACCOUNT_TOKEN
    Error: get session_expires_at_unix: read from keyring: secret not found in keyring, read from encoded file as fallback: value not found

Expected Behavior

  • The access token should be output to stdout.
  • Users should be able to capture the token reliably with:
export STACKIT_SERVICE_ACCOUNT_TOKEN=$(stackit auth get-access-token)
  • On success:
    • The environment variable contains the token.
  • On failure:
    • The environment variable remains empty.
    • The error message is output to stderr.

Impact

  • Automation and scripting are unnecessarily complicated.
  • There is a risk of storing error messages in the environment variable instead of a valid token.
  • This behavior does not align with standard CLI practices.

Suggested Fix

  • Output the access token to stdout.
  • Use stderr exclusively for error messages.
  • Optionally, provide a flag such as --output to specify the output stream, if needed.

Environment

$ uname -sm
Darwin arm64

$ stackit --version
STACKIT CLI (beta)
Version: 0.26.0 (2025-03-14)
@marceljk
Copy link
Contributor

Hi @rswrz,

thanks for reporting this issue. I create internal a ticket to fix this issue.

@rubenhoenle
Copy link
Member

Hey @rswrz,

this should be fixed with our latest release of the STACKIT CLI v0.29.0.

https://github.com/stackitcloud/stackit-cli/releases/tag/v0.29.0

I will close this issue for now, feel free to re-open if needed.

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

No branches or pull requests

3 participants