Skip to content

fix: Null iteration in kubectl-apply module#5430

Merged
sudheer-quad merged 1 commit into
GoogleCloudPlatform:developfrom
sudheer-quad:fix/kubectl-manifest-null-error
Mar 31, 2026
Merged

fix: Null iteration in kubectl-apply module#5430
sudheer-quad merged 1 commit into
GoogleCloudPlatform:developfrom
sudheer-quad:fix/kubectl-manifest-null-error

Conversation

@sudheer-quad

Copy link
Copy Markdown
Contributor

This PR fixes below error:

 Error: Iteration over null value
 on modules/embedded/modules/management/kubectl-apply/main.tf line 58, in locals:
  57:   enabled_manifests = {
  58:     for index, manifest in var.apply_manifests : index => manifest
  59:     if try(manifest.enable, true)
  60:   }
  ├────────────────
  │ var.apply_manifests is null

A null value cannot be used as the collection in a 'for' expression

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 runtime error occurring during Terraform execution where an attempt to iterate over a null variable caused the process to fail. By ensuring the input collection defaults to an empty list when null, the module now safely handles cases where no manifests are provided.

Highlights

  • Null pointer fix: Updated the iteration logic in the kubectl-apply module to handle null values for the apply_manifests variable.
  • Coalesce implementation: Utilized the coalesce function to default the input variable to an empty list when null, preventing runtime errors during Terraform evaluation.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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.

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.

@github-actions github-actions Bot added the external PR from external contributor label Mar 31, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request modifies the kubectl-apply module to prevent errors when var.apply_manifests is null by using the coalesce function during iteration. The reviewer suggests that a more robust approach, consistent with the repository's style guide, would be to set nullable = false in the variable definition within variables.tf to handle null values at the module boundary.

Comment thread modules/management/kubectl-apply/main.tf
@agrawalkhushi18

Copy link
Copy Markdown
Contributor

We need to modify the gke-a3-mega, gke-a3-ultra and gke-a4 blueprints by removing apply_manifests: field. That should resolve the error.

@sudheer-quad sudheer-quad force-pushed the fix/kubectl-manifest-null-error branch from 6de7f7c to f706d98 Compare March 31, 2026 07:00
@sudheer-quad sudheer-quad marked this pull request as ready for review March 31, 2026 07:02
@sudheer-quad sudheer-quad requested review from a team and samskillman as code owners March 31, 2026 07:02
@kadupoornima kadupoornima added the release-bugfix Added to release notes under the "Bug fixes" heading. label Mar 31, 2026
@agrawalkhushi18

Copy link
Copy Markdown
Contributor

LGTM!

@sudheer-quad sudheer-quad merged commit 2b9b9e6 into GoogleCloudPlatform:develop Mar 31, 2026
17 of 76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external PR from external contributor release-bugfix Added to release notes under the "Bug fixes" heading.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants