Skip to content

fix(sentry-kube): Print the credential fetch command to stderr - #261

Merged
mwarkentin merged 1 commit into
mainfrom
michaelwarkentin/sentry-kube-iap-echo-stderr
Oct 15, 2026
Merged

mwarkentin merged 1 commit into
mainfrom
michaelwarkentin/sentry-kube-iap-echo-stderr

Conversation

@mwarkentin

Copy link
Copy Markdown
Member

Summary

When a cluster's credentials aren't in the kubeconfig yet, ensure_iap_tunnel fetches them and prints the command it runs (Running: gcloud container clusters get-credentials ...) to stdout, ahead of the command's own output. On the first run against a cluster, that breaks machine-readable output, e.g.:

sentry-kube -C <region> cluster nodepools -o json | jq ...
# jq: parse error: Invalid numeric literal ...

This prints the line to stderr instead, matching the similar "Context not in kubeconfig. Adding cluster credentials with: ..." message in libsentrykube/utils.py. Interactive runs still show it.

Test plan

  • test_get_cluster_credentials_success now asserts the message is printed with err=True (fails without the fix)
  • Full suite: no new failures (two pre-existing environment-dependent failures: missing kube-linter binary, kubernetes client version)
  • pre-commit (ruff, ruff format, mypy) on the changed files

🤖 Generated with Claude Code

https://claude.ai/code/session_01Tpq2osA9FtohCFSg6dmBwF


Generated by Claude Code

When a cluster's credentials aren't in the kubeconfig yet, sentry-kube
prints the gcloud get-credentials command it runs to stdout, ahead of the
command's own output. That corrupts machine-readable output such as
`cluster nodepools -o json` on the first run against a cluster. Print it to
stderr, like the similar message in libsentrykube/utils.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tpq2osA9FtohCFSg6dmBwF
@mwarkentin
mwarkentin requested a review from a team as a code owner October 15, 2026 20:23
@mwarkentin
mwarkentin enabled auto-merge (squash) October 15, 2026 20:24
@mwarkentin
mwarkentin disabled auto-merge October 15, 2026 20:25
@mwarkentin
mwarkentin merged commit be676bc into main Oct 15, 2026
12 checks passed
@mwarkentin
mwarkentin deleted the michaelwarkentin/sentry-kube-iap-echo-stderr branch October 15, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants