fix(template): route registry client output to stderr so it doesn't corrupt manifest stdout#32234
Open
s3onghyun wants to merge 2 commits into
Open
fix(template): route registry client output to stderr so it doesn't corrupt manifest stdout#32234s3onghyun wants to merge 2 commits into
s3onghyun wants to merge 2 commits into
Conversation
…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]>
Contributor
There was a problem hiding this comment.
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 templatetocmd.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 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]>
Contributor
Author
|
Good catch — added |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 tokubectl 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 loginbut wrong forhelm template, whose stdout is the manifest stream. This PR passescmd.ErrOrStderr()to the registry client inpkg/cmd/template.goso 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 reportedhelm templateissue and verified there. AddedexecuteActionCommandStdoutStderrCbecause the existing test harness merged stdout+stderr into one buffer and couldn't catch this.If applicable:
docs neededlabel should be applied if so)