Skip to content

Conversation

lllamnyp
Copy link
Member

@lllamnyp lllamnyp commented Aug 19, 2025

A malformed access to the global context was preventing some helm charts from rendering correctly.

What this PR does

This patch fixes the issue.

Release note

[cozy-lib] Fix malformed retrieval of cozyConfig in cozy-lib template.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected configuration lookup for the network setting that controls disabling LoadBalancer node ports, ensuring defaults are applied when config is absent and behavior reflects enabled components.
  • Refactor
    • Simplified configuration retrieval path to use the root context for more reliable evaluation.

A malformed access to the global context was preventing some helm charts
from rendering correctly.

Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
@lllamnyp lllamnyp requested review from kvaps and klinch0 as code owners August 19, 2025 12:37
Copy link
Contributor

coderabbitai bot commented Aug 19, 2025

Walkthrough

The template now sources cozyConfig from the root context (index . "cozyConfig") instead of a nested context (index . 1 "cozyConfig"). All subsequent logic for computing enabled components and deciding defaultDisableLoadBalancerNodePorts inclusion remains unchanged.

Changes

Cohort / File(s) Summary
Template context access adjustment
packages/library/cozy-lib/templates/_network.tpl
Changed cozyConfig retrieval from index . 1 "cozyConfig" to index . "cozyConfig"; retained existing logic for enabled components and default inclusion.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A whisk of wind through templated ports,
I twitch my ears at root reports—
No nested burrow, straight to base,
The carrots route to proper place.
With toggles set and paths aligned,
Our warren’s load is well-defined. 🥕

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/incorrect-invocation-cozyconfig

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @lllamnyp, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug where Helm charts were failing to render as expected due to an incorrect method of accessing the "cozyConfig" variable within the "cozy-lib" template. The change rectifies this malformed access by adjusting the index used to retrieve the configuration from the global context. This ensures that "cozyConfig" is loaded properly, allowing affected Helm charts to render and function correctly.

Highlights

  • Corrected Configuration Access: The core issue was an incorrect index being used to access the "cozyConfig" variable within the Helm template. This fix ensures that the configuration is retrieved correctly.
  • Template Logic Refinement: The change specifically targets the "_network.tpl" file, modifying how "cozyConfig" is accessed to resolve rendering issues for certain Helm charts.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes a bug in the cozy-lib.network.disableLoadBalancerNodePorts Helm template. The change from index . 1 "cozyConfig" to index . "cozyConfig" corrects the method for accessing the cozyConfig map from the template's context. The original code was attempting to use an invalid integer index on a map, and this fix uses the proper string key, resolving the chart rendering issue. The change is accurate and well-contained.

@lllamnyp lllamnyp changed the title [cozy-lib] Fix incorrect retrieval of cozyConfig [cozy-lib] Fix malformed retrieval of cozyConfig Aug 19, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/library/cozy-lib/templates/_network.tpl (1)

20-21: Harden lookup and handle whitespace in bundle-enable list

If $cozyConfig exists but lacks data, index $cozyConfig.data "bundle-enable" can error before default is applied. Also, values like "metallb, robotlb" (notice the space) won’t match has "robotlb". Make the lookup nil-safe and split on comma with optional whitespace.

Apply this diff:

-{{-     $enabledComponents := splitList "," ((index $cozyConfig.data "bundle-enable") | default "") }}
-{{-     not (has "robotlb" $enabledComponents) }}
+{{-     $data := (index $cozyConfig "data") | default (dict) }}
+{{-     $raw := (index $data "bundle-enable") | default "" }}
+{{-     $enabledComponents := regexSplit "\\s*,\\s*" $raw -1 }}
+{{-     not (has "robotlb" $enabledComponents) }}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ba6460e and 46c2ee3.

📒 Files selected for processing (1)
  • packages/library/cozy-lib/templates/_network.tpl (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (2)
packages/library/cozy-lib/templates/_network.tpl (2)

16-16: Correctly sourcing cozyConfig from the root context

Good fix. Given the documented invocation pattern (include ... $), retrieving cozyConfig via index . "cozyConfig" is the right context and removes the dependency on the previous tuple-based access.


15-16: loadCozyConfig mutation verified

  • The helper in packages/library/cozy-lib/templates/_cozyconfig.tpl defines
    {{- $_ := set (index . 1) "cozyConfig" $cozyConfig }}
    
    which mutates the second argument—i.e. the original context passed in.
  • In _network.tpl (and in disableLoadBalancerNodePorts), you call
    {{- include "cozy-lib.loadCozyConfig" (list "" .) }}
    
    where . is the root context ($), and disableLoadBalancerNodePorts itself is invoked with $ as documented.
  • As a result,
    $cozyConfig := index . "cozyConfig"
    
    on line 16 will always return the loaded config.

@lllamnyp lllamnyp enabled auto-merge August 19, 2025 12:43
@lllamnyp lllamnyp merged commit c5b64af into main Aug 19, 2025
19 checks passed
@lllamnyp lllamnyp deleted the fix/incorrect-invocation-cozyconfig branch August 19, 2025 13:04
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.

3 participants