Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/kafka-ui/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ apiVersion: v2
name: kafka-ui
description: A Helm chart for kafka-UI
type: application
version: 1.6.3
version: 1.6.4
appVersion: v1.4.2
icon: https://raw.githubusercontent.com/kafbat/kafka-ui/main/documentation/images/logo_new.png
32 changes: 16 additions & 16 deletions charts/kafka-ui/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,42 +64,42 @@ spec:
{{- if .Values.yamlApplicationConfig }}
value: /kafka-ui/config.yml
{{- else if .Values.yamlApplicationConfigConfigMap }}
value: /kafka-ui/{{ .Values.yamlApplicationConfigConfigMap.keyName | default "config.yml" }}
value: /kafka-ui/{{ tpl (default "config.yml" .Values.yamlApplicationConfigConfigMap.keyName) . }}
{{- else if .Values.yamlApplicationConfigSecret }}
value: /kafka-ui/{{ .Values.yamlApplicationConfigSecret.keyName | default "config.yml" }}
value: /kafka-ui/{{ tpl (default "config.yml" .Values.yamlApplicationConfigSecret.keyName) . }}
{{- end }}
{{- end }}
{{- with .Values.env }}
{{- toYaml . | nindent 12 }}
{{- tpl (toYaml .) $ | nindent 12 }}
{{- end }}
{{- range $key, $value := .Values.envs.secretMappings }}
- name: {{ $key }}
valueFrom:
secretKeyRef:
name: {{ required "Missing required value envs.secretMappings.[].name" $value.name }}
key: {{ required "Missing required value envs.secretMappings.[].keyName" $value.keyName }}
name: {{ tpl (required "Missing required value envs.secretMappings.[].name" $value.name) $ | quote }}
key: {{ tpl (required "Missing required value envs.secretMappings.[].keyName" $value.keyName) $ | quote }}
{{- end }}
{{- range $key, $value := .Values.envs.configMappings }}
- name: {{ $key }}
valueFrom:
configMapKeyRef:
name: {{ required "Missing required value envs.configMappings.[].name" $value.name }}
key: {{ required "Missing required value envs.configMappings.[].keyName" $value.keyName }}
name: {{ tpl (required "Missing required value envs.configMappings.[].name" $value.name) $ | quote }}
key: {{ tpl (required "Missing required value envs.configMappings.[].keyName" $value.keyName) $ | quote }}
{{- end }}
{{- end }}
{{- if or .Values.existingConfigMap .Values.envs.config .Values.existingSecret .Values.envs.secret }}
envFrom:
{{- if .Values.existingConfigMap }}
- configMapRef:
name: {{ .Values.existingConfigMap }}
name: {{ tpl .Values.existingConfigMap . | quote }}
{{- end }}
{{- if .Values.envs.config }}
- configMapRef:
name: {{ include "kafka-ui.fullname" . }}
{{- end }}
{{- if .Values.existingSecret }}
- secretRef:
name: {{ .Values.existingSecret }}
name: {{ tpl .Values.existingSecret . | quote }}
{{- end }}
{{- if .Values.envs.secret}}
- secretRef:
Expand Down Expand Up @@ -141,8 +141,8 @@ spec:
{{- toYaml .Values.resources | nindent 12 }}
{{- if or .Values.yamlApplicationConfig .Values.volumeMounts .Values.yamlApplicationConfigConfigMap .Values.yamlApplicationConfigSecret }}
volumeMounts:
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- with .Values.volumeMounts }}
{{- tpl (toYaml .) $ | nindent 12 }}
{{- end }}
{{- if .Values.yamlApplicationConfig }}
- name: kafka-ui-yaml-conf
Expand All @@ -163,22 +163,22 @@ spec:
{{- if or .Values.yamlApplicationConfig .Values.volumes .Values.yamlApplicationConfigConfigMap .Values.yamlApplicationConfigSecret }}
volumes:
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- tpl (toYaml .) $ | nindent 8 }}
{{- end }}
{{- if .Values.yamlApplicationConfig }}
- name: kafka-ui-yaml-conf
configMap:
configMap:
name: {{ include "kafka-ui.fullname" . }}-fromvalues
{{- end }}
{{- if .Values.yamlApplicationConfigConfigMap}}
- name: kafka-ui-yaml-conf-configmap
configMap:
name: {{ .Values.yamlApplicationConfigConfigMap.name }}
configMap:
name: {{ tpl .Values.yamlApplicationConfigConfigMap.name . | quote }}
{{- end }}
{{- if .Values.yamlApplicationConfigSecret}}
- name: kafka-ui-yaml-conf-secret
secret:
secretName: {{ .Values.yamlApplicationConfigSecret.name }}
secretName: {{ tpl .Values.yamlApplicationConfigSecret.name . | quote }}
Comment on lines 173 to +181
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Apr 16, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In Helm templates, does calling tpl with a missing value (nil/) fail, and is wrapping the value with requiredbeforetpl the recommended way to surface a clear error for required string fields?

💡 Result:

Yes, calling tpl with a missing value (nil or ) fails the template rendering, typically with a "nil pointer evaluating interface" error or tpl execution error. Wrapping the value with required before passing to tpl is the recommended way to surface a clear, custom error for required string fields, as per official Helm documentation.

Citations:


🏁 Script executed:

# Check if the file exists and read lines 173-181
cat -n charts/kafka-ui/templates/deployment.yaml | sed -n '170,185p'

Repository: kafbat/helm-charts

Length of output: 794


🏁 Script executed:

# Search for existing uses of `required` in this file to understand existing patterns
grep -n "required" charts/kafka-ui/templates/deployment.yaml

Repository: kafbat/helm-charts

Length of output: 564


🏁 Script executed:

# Check for similar configMap/secret patterns in other templates
fd -e yaml charts/kafka-ui/templates/ | xargs grep -l "configMap\|secretName" | head -5

Repository: kafbat/helm-charts

Length of output: 471


🏁 Script executed:

# Search for similar patterns in other templates using correct fd syntax
fd . charts/kafka-ui/templates/ --type f -e yaml | xargs grep -n "tpl.*\.name" | grep -v "required"

Repository: kafbat/helm-charts

Length of output: 320


Add required guards before tpl to provide clear error messages for missing ConfigMap/Secret names.

Lines 176 and 181 pass .name values to tpl without validation. If either yamlApplicationConfigConfigMap or yamlApplicationConfigSecret is present without a name field, the template fails with a generic rendering error. The same file already uses this pattern successfully at lines 79, 80, 86, and 87. Align these lines with the existing pattern.

Suggested fix
         {{- if .Values.yamlApplicationConfigConfigMap}}
         - name: kafka-ui-yaml-conf-configmap
           configMap:
-            name: {{ tpl .Values.yamlApplicationConfigConfigMap.name . | quote }}
+            name: {{ tpl (required "Missing required value yamlApplicationConfigConfigMap.name" .Values.yamlApplicationConfigConfigMap.name) . | quote }}
         {{- end }}
         {{- if .Values.yamlApplicationConfigSecret}}
         - name: kafka-ui-yaml-conf-secret
           secret:
-            secretName: {{ tpl .Values.yamlApplicationConfigSecret.name . | quote }}
+            secretName: {{ tpl (required "Missing required value yamlApplicationConfigSecret.name" .Values.yamlApplicationConfigSecret.name) . | quote }}
         {{- end }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- if .Values.yamlApplicationConfigConfigMap}}
- name: kafka-ui-yaml-conf-configmap
configMap:
name: {{ .Values.yamlApplicationConfigConfigMap.name }}
configMap:
name: {{ tpl .Values.yamlApplicationConfigConfigMap.name . | quote }}
{{- end }}
{{- if .Values.yamlApplicationConfigSecret}}
- name: kafka-ui-yaml-conf-secret
secret:
secretName: {{ .Values.yamlApplicationConfigSecret.name }}
secretName: {{ tpl .Values.yamlApplicationConfigSecret.name . | quote }}
{{- if .Values.yamlApplicationConfigConfigMap}}
- name: kafka-ui-yaml-conf-configmap
configMap:
name: {{ tpl (required "Missing required value yamlApplicationConfigConfigMap.name" .Values.yamlApplicationConfigConfigMap.name) . | quote }}
{{- end }}
{{- if .Values.yamlApplicationConfigSecret}}
- name: kafka-ui-yaml-conf-secret
secret:
secretName: {{ tpl (required "Missing required value yamlApplicationConfigSecret.name" .Values.yamlApplicationConfigSecret.name) . | quote }}
{{- end }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/kafka-ui/templates/deployment.yaml` around lines 173 - 181, The
template currently calls tpl on .Values.yamlApplicationConfigConfigMap.name and
.Values.yamlApplicationConfigSecret.name without validating presence; update
those tpl calls to use the required function around the name keys so Helm will
emit clear errors if name is missing (match the pattern already used elsewhere
in this file for yamlApplicationConfigConfigMap/name and
yamlApplicationConfigSecret/name), keeping the surrounding keys
(kafka-ui-yaml-conf-configmap and kafka-ui-yaml-conf-secret) intact and quoting
the result as before.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That issue was present in the chart before this PR?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the git log for the original state of these lines before this PR
git log --oneline -5
git show HEAD~1:charts/kafka-ui/templates/deployment.yaml 2>/dev/null | sed -n '160,185p' || \
  git log --oneline --all | head -5

Length of output: 1369


🏁 Script executed:

#!/bin/bash
# Check the base branch (main) state of the file for these lines
git fetch origin main 2>/dev/null
git show origin/main:charts/kafka-ui/templates/deployment.yaml 2>/dev/null | grep -n "yamlApplicationConfigConfigMap\|yamlApplicationConfigSecret\|required\|tpl" | head -30

Length of output: 1774


@mohag — Partially, yes. On origin/main before this PR, those lines were:

name: {{ .Values.yamlApplicationConfigConfigMap.name }}
secretName: {{ .Values.yamlApplicationConfigSecret.name }}

— no tpl and no required. The lack of a required guard was pre-existing.

However, this PR introduces the tpl call on those values, which changes the failure mode:

  • Before this PR: a missing .name silently renders as <no value> in the YAML, producing a malformed but quietly broken manifest.
  • After this PR (current state): tpl on a nil value causes a hard template rendering error with a generic message.

Since the PR is already touching these lines to add tpl, it's a natural opportunity to also add required to match the pattern already used elsewhere in the same file for envs.secretMappings and envs.configMappings (lines 79, 80, 86, 87). That would give users a clear, actionable error message instead of a cryptic one.

{{- end }}
{{- end }}
{{- with .Values.nodeSelector }}
Expand Down
6 changes: 3 additions & 3 deletions charts/kafka-ui/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
{{- if .Values.ingress.tls.enabled }}
tls:
- hosts:
- {{ tpl .Values.ingress.host . }}
- {{ tpl .Values.ingress.host . | quote }}
secretName: {{ .Values.ingress.tls.secretName }}
{{- end }}
{{- if .Values.ingress.ingressClassName }}
Expand Down Expand Up @@ -70,7 +70,7 @@ spec:
number: {{ .servicePort }}
{{- end }}
{{- if tpl .Values.ingress.host . }}
host: {{tpl .Values.ingress.host . }}
host: {{ tpl .Values.ingress.host . | quote }}
{{- end }}
{{- else -}}
{{- range .Values.ingress.precedingPaths }}
Expand All @@ -92,7 +92,7 @@ spec:
servicePort: {{ .servicePort }}
{{- end }}
{{- if tpl .Values.ingress.host . }}
host: {{ tpl .Values.ingress.host . }}
host: {{ tpl .Values.ingress.host . | quote }}
{{- end }}
{{- end }}
{{- end }}