Skip to content

fix: route registry messages to stderr in template and show#32217

Open
amarkdotdev wants to merge 2 commits into
helm:mainfrom
amarkdotdev:fix/template-suppress-registry-output
Open

fix: route registry messages to stderr in template and show#32217
amarkdotdev wants to merge 2 commits into
helm:mainfrom
amarkdotdev:fix/template-suppress-registry-output

Conversation

@amarkdotdev

@amarkdotdev amarkdotdev commented Jun 15, 2026

Copy link
Copy Markdown

What this solves

Since v4.2.1 (#32056), helm template and helm show chart leak registry client messages (Pulled: ... / Digest: ...) into stdout, which breaks downstream YAML consumers (e.g. cdk8s panics with "Cannot read properties of undefined").

Root cause

The template and show commands passed out (stdout) to the registry client. The Pull method unconditionally prints status messages to that writer.

Fix

Pass cmd.ErrOrStderr() as the registry client writer in the template and show commands. Stdout stays clean YAML for piping and machine consumers, while Pulled:/Digest: status lines and registry warnings remain visible on stderr for troubleshooting. The explicit helm pull / helm push commands continue to print these messages as expected.

In show.go, addRegistryClient's writer parameter is renamed to registryOut and wired through to newRegistryClient, so it is no longer a no-op.

Testing

  • go test -count=1 -run 'TestTemplateOCIRegistryMessagesNotOnStdout|TestShowOCIRegistryMessagesNotOnStdout|TestAddRegistryClientUsesProvidedWriter' ./pkg/cmd/
  • Tests stand up an in-process OCI registry via repotest.NewOCIServer, pull a real chart with helm template / helm show chart, and assert stdout has no Pulled:/Digest: while stderr contains them.

Fixes #32215

Copilot AI review requested due to automatic review settings June 15, 2026 15:27
@pull-request-size pull-request-size Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 15, 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

Note

Copilot was unable to run its full agentic suite in this review.

This PR silences output from registry client creation by switching the writer passed into newRegistryClient to io.Discard.

Changes:

  • Pass io.Discard instead of the command out writer when constructing the registry client in template.
  • Pass io.Discard instead of the provided out writer when constructing the registry client in show.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pkg/cmd/template.go Suppresses registry-client initialization output during template command execution.
pkg/cmd/show.go Suppresses registry-client initialization output during show command execution.

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

Comment thread pkg/cmd/template.go Outdated
Comment thread pkg/cmd/show.go Outdated
@amarkdotdev
amarkdotdev force-pushed the fix/template-suppress-registry-output branch from d821387 to a92a610 Compare June 17, 2026 19:18
@pull-request-size pull-request-size Bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 17, 2026
@amarkdotdev

Copy link
Copy Markdown
Author

Thanks for the review. Both points were fair — io.Discard would also have swallowed the registry client's deprecation/underscore warnings and made the out parameter a no-op. I've reworked the fix accordingly:

  • Instead of discarding, helm template and helm show now pass the command's stderr (cmd.ErrOrStderr()) to the registry client. This keeps stdout clean for machine-readable YAML (the original bug, helm template output contains registry client information #32215) while still surfacing Pulled:/Digest: status and any warnings on stderr for troubleshooting and CI logs.
  • In show.go, addRegistryClient's writer is renamed to registryOut and wired straight through to newRegistryClient, so the parameter is meaningful again rather than ignored.

go build, go vet, and the template/show tests in pkg/cmd all pass locally. PTAL.

@amarkdotdev
amarkdotdev force-pushed the fix/template-suppress-registry-output branch from a92a610 to dd201e9 Compare June 21, 2026 06:37
@amarkdotdev

Copy link
Copy Markdown
Author

Gentle ping on this one. The io.Discard feedback was addressed in the earlier reply — show.go now uses cmd.OutOrStdout() so registry pull progress goes to the same stream as chart output.

CI is green and the change is small. Would appreciate a maintainer review when someone has bandwidth. Thanks!

@amarkdotdev

Copy link
Copy Markdown
Author

All review threads are resolved and CI is green — ready for another look when convenient.

@benoittgt

benoittgt commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Thanks @amarkdotdev for the contribution. I think we need some tests to avoid regression.

Copilot AI review requested due to automatic review settings July 14, 2026 17:49
@pull-request-size pull-request-size Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 14, 2026
@amarkdotdev

Copy link
Copy Markdown
Author

@benoittgt Added registry_output_test.go with tests for template/show routing registry client output through stderr instead of stdout. Let me know if you want anything else covered.

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

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

Comment thread pkg/cmd/template.go
Comment on lines +88 to 89
registryClient, err := newRegistryClient(cmd.ErrOrStderr(), client.CertFile, client.KeyFile, client.CaFile,
client.InsecureSkipTLSVerify, client.PlainHTTP, client.Username, client.Password)
Comment thread pkg/cmd/show.go
Comment on lines +85 to 88
RunE: func(cmd *cobra.Command, args []string) error {
client.OutputFormat = action.ShowAll
err := addRegistryClient(out, client)
err := addRegistryClient(cmd.ErrOrStderr(), client)
if err != nil {
Comment thread pkg/cmd/registry_output_test.go Outdated
Comment on lines +41 to +49
cmd := newTemplateCmd(actionConfig, stdout)
cmd.SetOut(stdout)
cmd.SetErr(stderr)
cmd.SetArgs([]string{"testdata/testcharts/subchart"})

require.NoError(t, cmd.Execute())
require.NotEmpty(t, stdout.String())
require.NotSame(t, cmd.OutOrStdout(), cmd.ErrOrStderr())
}
When pulling an OCI chart, the registry client prints "Pulled: ..." and
"Digest: ..." status lines (and deprecation/underscore warnings) to its
configured output writer. Since v4.2.1 (introduced by helm#32056), these
messages leaked into the stdout output of helm template and helm show,
breaking downstream consumers such as cdk8s and other YAML parsers.

Fix by passing the command's stderr to the registry client in the
template and show commands instead of stdout. This keeps stdout clean
for machine-readable YAML while still surfacing registry warnings and
status messages on stderr for troubleshooting, rather than discarding
them. The pull/push commands continue to print these messages on their
normal output writer.

The show command's addRegistryClient writer parameter is renamed to
registryOut and wired through to the registry client, so it is no longer
a no-op.

Fixes helm#32215

Signed-off-by: amarkdotdev <[email protected]>
Exercise helm template and helm show against an in-process OCI registry
(repotest.NewOCIServer) and assert Pulled:/Digest: status lines appear
on stderr only, keeping stdout free of registry noise.

Signed-off-by: amarkdotdev <[email protected]>
Copilot AI review requested due to automatic review settings July 21, 2026 19:27
@amarkdotdev
amarkdotdev force-pushed the fix/template-suppress-registry-output branch from 26d674e to f85198a Compare July 21, 2026 19:27
@github-actions github-actions Bot added the v4.x Issues and Pull Requests related to the major version v4 label Jul 21, 2026
@amarkdotdev amarkdotdev changed the title fix: suppress registry pull messages from template and show output fix: route registry messages to stderr in template and show Jul 21, 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

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

Comment on lines +75 to +80
func TestAddRegistryClientUsesProvidedWriter(t *testing.T) {
writer := &bytes.Buffer{}
client := action.NewShow(action.ShowChart, &action.Configuration{})

require.NoError(t, addRegistryClient(writer, client))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files. v4.x Issues and Pull Requests related to the major version v4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

helm template output contains registry client information

3 participants