Description
Versions:
- Controller Version: v0.1.3
- Chart Version: 0.1.3
When using the gt function in a Helm template to compare a value (e.g., .Values.controller.replicas) with a float literal like 1.0, the template fails if the value is an int.
Example:
values.yaml
controller:
....replicas: 2
template
{{- if gt .Values.controller.replicas 1.0 -}}
...
{{- end -}}
Files affected:
This issue occurs in the following templates:
- charts/local-pvc-releaser/templates/rbac/leader_election_role_binding.yaml
- charts/local-pvc-releaser/templates/rbac/leader_election_role.yaml
- charts/local-pvc-releaser/templates/manager/deployment.yaml
Error:
error calling gt: incompatible types for comparison
This is surprising because in most languages, comparing int to float works transparently (e.g., 2 > 1.0 is valid).
Expected behavior:
gt should handle numeric comparisons between int and float where possible, or at least provide a clearer error message or helper functions for type conversion.
Actual behavior:
The template engine throws a runtime error when comparing int with float64.
Suggested fix:
{{- if gt (int .Values.controller.replicas) 1 -}}
Helm version:
version.BuildInfo{Version:"v3.18.0", GitCommit:"cc58e3f5a3aa615c6a86275e6f4444b5fdd3cc4e", GitTreeState:"clean", GoVersion:"go1.24.3"}
Regression Note:
In earlier versions of Helm (with older Go versions), this comparison did not fail at runtime, and mixed-type comparisons (int with float) were handled more permissively.
After Helm upgraded its Go version (e.g., Go 1.20+), the stricter type safety in Go templates has made this behavior a breaking change in practice, even though it is not documented as such.
Description
Versions:
When using the gt function in a Helm template to compare a value (e.g., .Values.controller.replicas) with a float literal like 1.0, the template fails if the value is an int.
Example:
values.yaml
template
Files affected:
This issue occurs in the following templates:
Error:
This is surprising because in most languages, comparing int to float works transparently (e.g., 2 > 1.0 is valid).
Expected behavior:
gt should handle numeric comparisons between int and float where possible, or at least provide a clearer error message or helper functions for type conversion.
Actual behavior:
The template engine throws a runtime error when comparing int with float64.
Suggested fix:
Helm version:
Regression Note:
In earlier versions of Helm (with older Go versions), this comparison did not fail at runtime, and mixed-type comparisons (int with float) were handled more permissively.
After Helm upgraded its Go version (e.g., Go 1.20+), the stricter type safety in Go templates has made this behavior a breaking change in practice, even though it is not documented as such.