From c6fec4cb35238e7d130ec131824ce31ca8678f8d Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Wed, 10 Sep 2025 12:35:53 +0200 Subject: [PATCH] Fix error message trimming for dynamic schema paths in JSON validation Previously, the error trimming was hardcoded to remove only: 'jsonschema validation failed with 'file:///values.schema.json#'' After the fix for relative schema references (issue #31260), schema URLs now include the full absolute path, making error messages look like: 'jsonschema validation failed with 'file:///full/absolute/path/values.schema.json#'' Signed-off-by: Benoit Tigeot --- pkg/chart/common/util/jsonschema.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/chart/common/util/jsonschema.go b/pkg/chart/common/util/jsonschema.go index 621987d51..953a20124 100644 --- a/pkg/chart/common/util/jsonschema.go +++ b/pkg/chart/common/util/jsonschema.go @@ -167,7 +167,11 @@ func (e JSONSchemaValidationError) Error() string { // This string prefixes all of our error details. Further up the stack of helm error message // building more detail is provided to users. This is removed. - errStr = strings.TrimPrefix(errStr, "jsonschema validation failed with 'file:///values.schema.json#'\n") + if strings.HasPrefix(errStr, "jsonschema validation failed with ") { + if idx := strings.Index(errStr, "#'\n"); idx != -1 { + errStr = errStr[idx+3:] + } + } // The extra new line is needed for when there are sub-charts. return errStr + "\n"