Skip to content

fix: handle YAML parse errors in find_templates_of_type - #166

Merged
dislbenn merged 1 commit into
mainfrom
fix/find-templates-yaml-parse-error
Jul 24, 2026
Merged

fix: handle YAML parse errors in find_templates_of_type#166
dislbenn merged 1 commit into
mainfrom
fix/find-templates-yaml-parse-error

Conversation

@dislbenn

Copy link
Copy Markdown
Collaborator

Description

find_templates_of_type in generate-charts.py crashes when encountering templates wrapped with Helm conditionals (e.g. {{- if .Values.global.networkPolicies.enabled }}). The {{ syntax is interpreted as a YAML flow mapping, causing yaml.safe_load to fail. This was introduced when NetworkPolicy wrapping was added — the wrapping phase modifies template files, then a later phase tries to parse all templates and crashes on the modified ones.

Related Issue

Caused by #164 / #165 which added NetworkPolicy conditional wrapping to chart generation.

Changes Made

  • Added try/except yaml.YAMLError around yaml.safe_load in find_templates_of_type to skip unparseable templates
  • Added null check on fileYml and switched from fileYml['kind'] to fileYml.get('kind') to prevent KeyError/TypeError
  • Aligns generate-charts.py with bundles-to-charts.py which already handles this correctly

Screenshots (if applicable)

N/A

Checklist

  • I have tested the changes locally and they are functioning as expected.
  • I have updated the documentation (if necessary) to reflect the changes.
  • I have added/updated relevant unit tests (if applicable).
  • I have ensured that my code follows the project's coding standards.
  • I have checked for any potential security issues and addressed them.
  • I have added necessary comments to the code, especially in complex or unclear sections.
  • I have rebased my branch on top of the latest main/master branch.

Additional Notes

N/A

Reviewers

/cc @cameronmwall @ngraham20

Definition of Done

  • Code is reviewed.
  • Code is tested.
  • Documentation is updated.
  • All checks and tests pass.
  • Approved by at least one reviewer.
  • Merged into the main/master branch.

Templates wrapped with Helm conditionals (e.g. {{- if }}) by earlier
phases cannot be parsed by yaml.safe_load. This aligns generate-charts.py
with bundles-to-charts.py which already handles this with try/except.

Signed-off-by: dislbenn <dbennett@redhat.com>

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-ci
openshift-ci Bot requested review from cameronmwall and ngraham20 July 24, 2026 15:03
@openshift-ci

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dislbenn

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@dislbenn, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 27 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository: stolostron/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 157f8865-e82b-49e1-bee8-9428efb95ab0

📥 Commits

Reviewing files that changed from the base of the PR and between 0436c52 and 63e3428.

📒 Files selected for processing (1)
  • scripts/bundle-generation/generate-charts.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/find-templates-yaml-parse-error

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dislbenn
dislbenn merged commit 1970848 into main Jul 24, 2026
5 of 6 checks passed
@dislbenn
dislbenn deleted the fix/find-templates-yaml-parse-error branch July 24, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant