Skip to content

Default HookOutputFunc to io.Discard to fix panic on hook-output-log-policy - #1563

Open
pujitha24 wants to merge 1 commit into
fluxcd:mainfrom
pujitha24:auto/issue-1562
Open

Default HookOutputFunc to io.Discard to fix panic on hook-output-log-policy#1563
pujitha24 wants to merge 1 commit into
fluxcd:mainfrom
pujitha24:auto/issue-1562

Conversation

@pujitha24

Copy link
Copy Markdown

Motivation:
helm-controller crashes with a nil pointer dereference whenever a chart hook Pod/Job carries the helm.sh/hook-output-log-policy annotation, because Helm dereferences cfg.HookOutputFunc without a nil check, and ConfigFactory.Build() never set that field.

Approach:
Set HookOutputFunc on the configuration returned by ConfigFactory.Build() in internal/action/config.go to a function returning io.Discard, matching the default Helm's own CLI initialization uses, so hook container logs are discarded instead of causing a nil dereference.

Validation:
Added a unit test in internal/action/config_test.go asserting ConfigFactory.Build().HookOutputFunc is non-nil and returns io.Discard.

Report: #1562
Signed-off-by: Pujitha Paladugu 10557236+pujitha24@users.noreply.github.com
Assisted-by: claude-sonnet-5 (via Claude Code)

…policy

Motivation:
helm-controller crashes with a nil pointer dereference whenever a chart hook Pod/Job carries the `helm.sh/hook-output-log-policy` annotation, because Helm dereferences `cfg.HookOutputFunc` without a nil check, and `ConfigFactory.Build()` never set that field.

Approach:
Set `HookOutputFunc` on the configuration returned by `ConfigFactory.Build()` in internal/action/config.go to a function returning `io.Discard`, matching the default Helm's own CLI initialization uses, so hook container logs are discarded instead of causing a nil dereference.

Validation:
Added a unit test in internal/action/config_test.go asserting `ConfigFactory.Build().HookOutputFunc` is non-nil and returns `io.Discard`.

Report: fluxcd#1562
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Assisted-by: claude-sonnet-5 (via Claude Code)
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.

1 participant