Skip to content

Fix helm chart error when value cannot be compared to nil#2983

Closed
cccs-cat001 wants to merge 9 commits intoapache:mainfrom
cccs-cat001:main
Closed

Fix helm chart error when value cannot be compared to nil#2983
cccs-cat001 wants to merge 9 commits intoapache:mainfrom
cccs-cat001:main

Conversation

@cccs-cat001
Copy link
Contributor

I faced an issue deploying the helm chart with this line. I found that comparing with nil is unnecessary, because you can just do what's proposed. Sometimes an object/string/map is incompatible with nil and the helm chart will throw errors.

Checklist

  • 🛡️ Don't disclose security issues! (contact [email protected])
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

{{- $global := index . 2 -}}
{{- $valAsString := "" -}}
{{- if ne $value nil -}}
{{- if $value -}}
Copy link
Contributor

Choose a reason for hiding this comment

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

We really want this to be if ne $value nil. This is unusual, I know, but here we need to distinguish other zero-values from nil. For example, foo: false or foo: 0 should result in the config property foo being included in the ConfigMap, with value false or 0.

If we change this as you suggested, these properties would not be included.

Taking a step back, can you show us a test case that is currently failing? This would help us understand your issue and fix it. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I really have no idea what values it was failing on. Helm has been pretty useless in telling me where it went wrong.

Error: template: catalog/charts/polaris/templates/configmap.yaml:216:7: executing "catalog/charts/polaris/templates/configmap.yaml" at <include "polaris.appendConfigOption" (list $k $v $global)>: error calling include: template: catalog/charts/polaris/templates/_helpers.tpl:145:7: executing "polaris.appendConfigOption" at <ne $value nil>: error calling ne: incompatible types for comparison
helm.go:81: [debug] template: catalog/charts/polaris/templates/configmap.yaml:216:7: executing "catalog/charts/polaris/templates/configmap.yaml" at <include "polaris.appendConfigOption" (list $k $v $global)>: error calling include: template: catalog/charts/polaris/templates/_helpers.tpl:145:7: executing "polaris.appendConfigOption" at <ne $value nil>: error calling ne: incompatible types for comparison

Copy link
Contributor

Choose a reason for hiding this comment

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

OK but what was your values file? So that I can reproduce and debug :-)

@dimas-b
Copy link
Contributor

dimas-b commented Nov 7, 2025

@cccs-cat001 you pushed and closed this PR? Was it intentional or by mistake? :)

@cccs-cat001
Copy link
Contributor Author

I am very bad at git, it was definitely a mistake 😆

Haven't had the time to create a minimal example for this sorry, I'll get to it next week!

@dimas-b dimas-b reopened this Nov 7, 2025
@github-project-automation github-project-automation bot moved this from Done to PRs In Progress in Basic Kanban Board Nov 7, 2025
@cccs-cat001
Copy link
Contributor Author

I can't seem to reproduce this again. It must've been some config I was using last week that has since changed, or possibly the outdated version of helm that I was using.

I think we're safe to close this as a user error :P

@adutra
Copy link
Contributor

adutra commented Nov 10, 2025

Thanks for confirming that everything is working on your end @cccs-cat001 ! Closing as per your request.

@adutra adutra closed this Nov 10, 2025
@github-project-automation github-project-automation bot moved this from PRs In Progress to Done in Basic Kanban Board Nov 10, 2025
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