Skip to content

fix(template): route registry client output to stderr so it doesn't corrupt manifest stdout#32234

Open
s3onghyun wants to merge 2 commits into
helm:mainfrom
s3onghyun:fix-template-oci-stdout
Open

fix(template): route registry client output to stderr so it doesn't corrupt manifest stdout#32234
s3onghyun wants to merge 2 commits into
helm:mainfrom
s3onghyun:fix-template-oci-stdout

Conversation

@s3onghyun

@s3onghyun s3onghyun commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

helm template oci://... prints the registry client's diagnostic lines (Pulled:, Digest:) to stdout, intermixed with the rendered Kubernetes manifests, so piping to kubectl apply -f - fails on corrupted YAML.

This is a regression from #32056 ("route registry client output to stdout"), which is correct for helm pull/push/registry login but wrong for helm template, whose stdout is the manifest stream. This PR passes cmd.ErrOrStderr() to the registry client in pkg/cmd/template.go so diagnostics go to stderr, restoring the pre-regression behavior while keeping #32056's intent for the other commands.

closes #32215

Special notes for your reviewer:

The same regression theoretically affects helm install/upgrade (their stdout carries release notes), but those are separate behaviors; this fix is scoped to the reported helm template issue and verified there. Added executeActionCommandStdoutStderrC because the existing test harness merged stdout+stderr into one buffer and couldn't catch this.

If applicable:

  • this PR contains user facing changes (the docs needed label should be applied if so)
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

…orrupt manifest stdout

helm template oci://... printed the registry client's "Pulled:" and
"Digest:" diagnostics to stdout, intermixed with the rendered manifests,
so piping to `kubectl apply -f -` failed. This is a regression from helm#32056,
which rewired the registry client writer to the command's stdout (correct for
pull/push/login, but not for template whose stdout is the manifest stream).

Route the registry client output to stderr for the template command, restoring
the pre-regression behavior while keeping helm#32056's intent for other commands.

Closes helm#32215

Signed-off-by: Seonghyun Hong <[email protected]>
Copilot AI review requested due to automatic review settings June 18, 2026 12:22
@pull-request-size pull-request-size Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a regression where OCI registry client status lines (e.g., Pulled:, Digest:) were written into helm template’s manifest output stream, corrupting YAML when piping to tools like kubectl apply -f -.

Changes:

  • Route the registry client writer in helm template to cmd.ErrOrStderr() so manifests remain clean on stdout.
  • Add a test helper that captures stdout and stderr separately for command execution in tests.
  • Add a regression test that ensures registry output does not appear in the rendered manifest stdout when templating an OCI chart.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
pkg/cmd/template.go Uses cmd.ErrOrStderr() for registry client output to avoid corrupting manifest stdout.
pkg/cmd/template_test.go Adds regression test verifying OCI registry output does not leak into manifest stdout.
pkg/cmd/helpers_test.go Adds a test helper to capture stdout/stderr into separate buffers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/cmd/template_test.go
Comment on lines +187 to +188
func TestTemplateOCIRegistryOutputNotInManifest(t *testing.T) {
srv := repotest.NewTempServer(
Add defer resetEnv()() so the test isolates the package-global settings/env,
matching the other cmd tests and avoiding order-dependent flakiness.

Signed-off-by: Seonghyun Hong <[email protected]>
@s3onghyun

Copy link
Copy Markdown
Contributor Author

Good catch — added defer resetEnv()() to the test so it resets the package-global settings/env like the other cmd tests, avoiding order-dependent flakiness. go test ./pkg/cmd/ stays green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

helm template output contains registry client information

2 participants