Skip to content

[airflow-ctl/v0-1-test] Keep airflowctl auth token stdout limited to the token (#76134) - #76195

Merged
shahar1 merged 1 commit into
airflow-ctl/v0-1-testfrom
backport-283ab98-airflow-ctl/v0-1-test
Nov 1, 2026
Merged

shahar1 merged 1 commit into
airflow-ctl/v0-1-testfrom
backport-283ab98-airflow-ctl/v0-1-test

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor
  • Keep airflowctl auth token stdout limited to the token

airflowctl auth token is meant to be captured, e.g.
TOKEN=$(airflowctl auth token ...). The username prompt was written to
stdout via input(), so in that usage the prompt was invisible to the user
and ended up inside the captured value; the failure message also went to
stdout. Without a TTY and without credentials, the command crashed with
an EOFError traceback instead of a clear error.

Prompts and errors now go to stderr, and missing credentials in a
non-interactive context exit with a clear message, mirroring what
airflowctl auth login already does.

  • Let airflowctl auth token read a piped password without a TTY

Only refuse to run when the username is missing and stdin is not a
TTY (or is closed); the password still goes through getpass, which
reads from /dev/tty when available and falls back to stdin. This keeps
'echo "$PW" | airflowctl auth token --username u' and prompts on
/dev/tty with redirected stdin working, so scripts need not put the
password on argv. EOF while reading the password exits 1 with a clear
stderr message. Document the non-interactive options in the help text.
(cherry picked from commit 283ab98)

Co-authored-by: Shawn Sun [email protected]

…the token (#76134)

* Keep airflowctl auth token stdout limited to the token

`airflowctl auth token` is meant to be captured, e.g.
`TOKEN=$(airflowctl auth token ...)`. The username prompt was written to
stdout via input(), so in that usage the prompt was invisible to the user
and ended up inside the captured value; the failure message also went to
stdout. Without a TTY and without credentials, the command crashed with
an EOFError traceback instead of a clear error.

Prompts and errors now go to stderr, and missing credentials in a
non-interactive context exit with a clear message, mirroring what
`airflowctl auth login` already does.

* Let airflowctl auth token read a piped password without a TTY

Only refuse to run when the username is missing and stdin is not a
TTY (or is closed); the password still goes through getpass, which
reads from /dev/tty when available and falls back to stdin. This keeps
'echo "$PW" | airflowctl auth token --username u' and prompts on
/dev/tty with redirected stdin working, so scripts need not put the
password on argv. EOF while reading the password exits 1 with a clear
stderr message. Document the non-interactive options in the help text.
(cherry picked from commit 283ab98)

Co-authored-by: Shawn Sun <[email protected]>
@shahar1
shahar1 marked this pull request as ready for review November 1, 2026 07:38
@shahar1
shahar1 merged commit 1050a35 into airflow-ctl/v0-1-test Nov 1, 2026
13 checks passed
@shahar1
shahar1 deleted the backport-283ab98-airflow-ctl/v0-1-test branch November 1, 2026 07:44
shahar1 pushed a commit that referenced this pull request Nov 19, 2026
…the token (#76134) (#76195)

* Keep airflowctl auth token stdout limited to the token

`airflowctl auth token` is meant to be captured, e.g.
`TOKEN=$(airflowctl auth token ...)`. The username prompt was written to
stdout via input(), so in that usage the prompt was invisible to the user
and ended up inside the captured value; the failure message also went to
stdout. Without a TTY and without credentials, the command crashed with
an EOFError traceback instead of a clear error.

Prompts and errors now go to stderr, and missing credentials in a
non-interactive context exit with a clear message, mirroring what
`airflowctl auth login` already does.

* Let airflowctl auth token read a piped password without a TTY

Only refuse to run when the username is missing and stdin is not a
TTY (or is closed); the password still goes through getpass, which
reads from /dev/tty when available and falls back to stdin. This keeps
'echo "$PW" | airflowctl auth token --username u' and prompts on
/dev/tty with redirected stdin working, so scripts need not put the
password on argv. EOF while reading the password exits 1 with a clear
stderr message. Document the non-interactive options in the help text.
(cherry picked from commit 283ab98)

Co-authored-by: Shawn Sun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants