Skip to content

Helm render error logs#182

Merged
whitemerch merged 2 commits into
mainfrom
chakib.hamie/collapse_helm_render_error_logs
Jun 15, 2026
Merged

Helm render error logs#182
whitemerch merged 2 commits into
mainfrom
chakib.hamie/collapse_helm_render_error_logs

Conversation

@whitemerch

@whitemerch whitemerch commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Motivation

Many Helm charts in large monorepos are deployed via build systems that inject additional value files at deploy time (release names, datacenter config, OCI image references, etc.) that are not present in the chart's own values.yaml. The scanner cannot replicate that injection at scan time, so rendering those charts fails with Go template missing-value errors. This is a known, intentional limitation: full value resolution from build metadata would require parsing BAZEL files, which is out of scope given the complexity and narrow population of affected charts.

The consequence of these render failures was a severe log-level problem, not a loss of findings. When rendering fails the scanner falls back to scanning raw template files, which still detects and emits genuine security findings, the only degradation is that resource_name may contain an unresolved template expression rather than the concrete deployed name. Each render failure was producing 3–4 duplicate ERROR lines across independent pipeline layers, compounding further because each raw template file containing Go template syntax then produced an additional ERROR from the YAML parser. None of these logs carried information not already available at the outermost layer, and their volume made the ERROR logs noisy relative to failures that actually warrant attention.

Changes

Helm resolver

All Error() calls in runInstall and renderHelm are removed. Every failure path in those functions now returns the error silently. The resolverSink is the canonical signal for a chart render failure and now carries the full specific error message via errors.Wrap rather than the generic message that previously discarded the underlying cause.

Render-failure classification

resolverSink now distinguishes expected render failures (charts that reference deploy-time values absent at scan time, identified by well-known Go template missing-value error signatures) from unexpected ones. Expected failures log at Debug and register the chart directory as a known fallback; any other render failure stays at Error. The fallback announcement in resolveChartDir is similarly demoted to Debug since the render error is already logged by the layer below.

Raw template parse errors

Service tracks which chart directories failed to render. When the YAML parser fails on a file inside one of those directories, the expected outcome for raw Go templates, the error is logged at Debug. Parse failures on all other files remain at Error, preserving visibility into genuine parser bugs.

Author Checklist

  • I have reviewed my own PR.
  • I have added or updated relevant unit tests where necessary. If no tests are added, I've explained why.
  • All new and existing tests pass.
  • I have tested my changes on staging (if applicable).
  • I have updated any relevant documentation (if applicable).

QA Instruction

  1. go test ./pkg/runner/... ./pkg/resolver/helm/... ./pkg/engine/provider/...
  2. Scan a Helm chart that requires deploy-time values and confirm: zero ERROR lines are emitted for that chart, the raw template files inside it produce no ERROR, and a single Debug line with the specific template error is present when debug logging is enabled.
  3. Scan a non-Helm YAML file with intentionally invalid syntax and confirm the parse failure still surfaces at Error.

Impact

Only the Helm rendering and raw-template fallback path are affected. No scan results, rule logic, or output formats change, only log levels for known, handled failure conditions are reduced.

Additional Notes

I submit this contribution under the Apache-2.0 license.

@whitemerch
whitemerch force-pushed the chakib.hamie/collapse_helm_render_error_logs branch from 1672ebb to 39fc84f Compare June 11, 2026 19:57
@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Jun 11, 2026

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 77.50%
Overall Coverage: 48.31% (+0.33%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 116f28d | Docs | Datadog PR Page | Give us feedback!

@whitemerch
whitemerch force-pushed the chakib.hamie/collapse_helm_render_error_logs branch from 39fc84f to 012c2b6 Compare June 11, 2026 20:00
@whitemerch whitemerch changed the title [K9VULN-16234] Collapse Helm render error logs to one line per failure Collapse Helm render error logs to one line per failure Jun 11, 2026
…h failure produces one log line at the outermost resolver sink.
@whitemerch
whitemerch force-pushed the chakib.hamie/collapse_helm_render_error_logs branch from 012c2b6 to 5a5d438 Compare June 11, 2026 20:02
@whitemerch whitemerch changed the title Collapse Helm render error logs to one line per failure Helm render error logs Jun 12, 2026
@whitemerch
whitemerch marked this pull request as ready for review June 12, 2026 08:04
@whitemerch
whitemerch requested a review from a team as a code owner June 12, 2026 08:04
@whitemerch
whitemerch marked this pull request as draft June 12, 2026 08:48
@whitemerch
whitemerch force-pushed the chakib.hamie/collapse_helm_render_error_logs branch 6 times, most recently from 619686e to e0c9a59 Compare June 12, 2026 10:35
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@whitemerch
whitemerch force-pushed the chakib.hamie/collapse_helm_render_error_logs branch from e0c9a59 to 229d590 Compare June 12, 2026 11:35
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@whitemerch
whitemerch force-pushed the chakib.hamie/collapse_helm_render_error_logs branch from 229d590 to f34a9fd Compare June 12, 2026 12:08
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@whitemerch
whitemerch force-pushed the chakib.hamie/collapse_helm_render_error_logs branch from f34a9fd to 1a13150 Compare June 12, 2026 12:23
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@whitemerch
whitemerch force-pushed the chakib.hamie/collapse_helm_render_error_logs branch from 1a13150 to 116f28d Compare June 12, 2026 12:54
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 116f28d1ad

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@whitemerch
whitemerch marked this pull request as ready for review June 12, 2026 12:58

@MikaYuoadas MikaYuoadas 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.

LGTM, just asked a question to clarify one change.

}
// The render failure is already logged by the resolver sink; this is
// just the fallback announcement, so keep it at Debug.
contextLogger.Debug().Msgf("Scanning raw files of Helm chart '%s' as a fallback after render failure", path)

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.

Question: Why remove the Chart.yaml guard? Do we want to emit this log-line for non Helm chart folder too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The guard in resolveChartDir was already redundant, resolveChartDir is only reachable after checkConditions passes for a directory, and checkConditions already gates on Chart.yaml existing (lines 427-430). Any path reaching resolveChartDir is guaranteed to be a Helm chart root, so the Debug log can only fire there

@whitemerch
whitemerch merged commit 7c05866 into main Jun 15, 2026
19 checks passed
@whitemerch
whitemerch deleted the chakib.hamie/collapse_helm_render_error_logs branch June 15, 2026 16:11
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