From 3b374fb43179df72414ae766f70bcaeb7e429524 Mon Sep 17 00:00:00 2001 From: bussyjd Date: Thu, 13 Nov 2025 11:41:39 -0300 Subject: [PATCH] Enhance validator client type validation with actionable error messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improves the validator client type validation error messages to provide better user guidance when invalid types are specified. Changes: - Add generic fuzzy matching for "did you mean" suggestions * Known typos map: loki→lodestar, prism→prysm, lighthose→lighthouse * Prefix matching: tek→teku, nim→nimbus, lodest→lodestar * Substring matching for partial matches - Provide actionable fix instructions showing: * CLI flag syntax: --set validatorClient.type= * values.yaml format with proper indentation * Custom values file approach - Include documentation reference to README.md - Use suggested type in examples when available Example error output: ERROR: Invalid validator client type 'loki'. Valid options: lighthouse, lodestar, teku, prysm, nimbus ⚠️ Did you mean 'lodestar'? How to fix this: • Using --set flag: --set validatorClient.type=lodestar • In your values.yaml file: validatorClient: type: lodestar Tested with all validator client types and various typos. All valid types (lighthouse, lodestar, teku, prysm, nimbus) still work correctly. Addresses user feedback from PR #148 that validation errors needed more actionable guidance. --- charts/dv-pod/templates/_helpers.tpl | 39 +++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/charts/dv-pod/templates/_helpers.tpl b/charts/dv-pod/templates/_helpers.tpl index 1305d76..219768a 100644 --- a/charts/dv-pod/templates/_helpers.tpl +++ b/charts/dv-pod/templates/_helpers.tpl @@ -156,7 +156,44 @@ Validate validator client type {{- $validTypes := list "lighthouse" "lodestar" "teku" "prysm" "nimbus" -}} {{- $currentType := .Values.validatorClient.type -}} {{- if not (has $currentType $validTypes) -}} -{{- fail (printf "ERROR: Invalid validator client type '%s'. Valid options are: %s" $currentType (join ", " $validTypes)) -}} +{{- $errorMsg := printf "\n\nERROR: Invalid validator client type '%s'.\n\nValid options: %s" $currentType (join ", " $validTypes) -}} +{{- /* Try to find the closest match using simple heuristics */ -}} +{{- $suggestion := "" -}} +{{- $currentLower := lower $currentType -}} +{{- /* Check for common typos and confusions */ -}} +{{- $typoMap := dict "loki" "lodestar" "lodestar-" "lodestar" "lighthose" "lighthouse" "lighthouse-" "lighthouse" "tekku" "teku" "teku-" "teku" "prisim" "prysm" "prism" "prysm" "prysm-" "prysm" "nimbos" "nimbus" "nimbus-" "nimbus" -}} +{{- if hasKey $typoMap $currentLower -}} +{{- $suggestion = get $typoMap $currentLower -}} +{{- else -}} +{{- /* Check for prefix matches (at least 2 characters) */ -}} +{{- range $validType := $validTypes -}} +{{- $validLower := lower $validType -}} +{{- if and (gt (len $currentLower) 1) (hasPrefix $validLower (substr 0 2 $currentLower)) -}} +{{- $suggestion = $validType -}} +{{- end -}} +{{- if and (gt (len $currentLower) 2) (hasPrefix $validLower (substr 0 3 $currentLower)) -}} +{{- $suggestion = $validType -}} +{{- end -}} +{{- /* Check if valid type contains the input or vice versa */ -}} +{{- if and (gt (len $currentLower) 2) (contains $validLower $currentLower) -}} +{{- $suggestion = $validType -}} +{{- end -}} +{{- if and (gt (len $currentLower) 2) (contains $currentLower $validLower) -}} +{{- $suggestion = $validType -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- /* Add suggestion to error message if found */ -}} +{{- if $suggestion -}} +{{- $errorMsg = printf "%s\n\n⚠️ Did you mean '%s'?" $errorMsg $suggestion -}} +{{- end -}} +{{- /* Use suggestion if available, otherwise use lodestar as example */ -}} +{{- $exampleType := "lodestar" -}} +{{- if $suggestion -}} +{{- $exampleType = $suggestion -}} +{{- end -}} +{{- $errorMsg = printf "%s\n\nHow to fix this:\n • Using --set flag:\n --set validatorClient.type=%s\n\n • In your values.yaml file:\n validatorClient:\n type: %s\n\n • Using custom values file:\n helm install my-dv-pod obol/dv-pod -f myvalues.yaml\n\nFor more information, see the Validator Client section in charts/dv-pod/README.md\n" $errorMsg $exampleType $exampleType -}} +{{- fail $errorMsg -}} {{- end -}} {{- end -}} {{- end -}}