From 767e2be5284ab19ebab5ea217bbef704c895286d Mon Sep 17 00:00:00 2001 From: Ben Lavery-Griffiths Date: Mon, 8 Sep 2025 10:49:41 +0100 Subject: [PATCH] Fix referencing another schema file relative to CWD After the switch to github.com/santhosh-tekuri/jsonschema/v6 we noticed that one of our charts was failing with the following error: > Error: values don't meet the specifications of the schema(s) in the following chart(s): > my-chart: > failing loading "file://./schema/library.json": open /schema/library.json: no such file or directory Checking against helm v3.18.4 (the last version of helm to use the old jsonschema module) everything worked as expected. From what I can tell, the newly adopted jsonschema module automatically prefixes "file://" onto the schema path, and any references within the main values.schema.json This commit, as best as I can test, puts back the behaviour found in v3.18.4 where executing a helm subcommand that validates against a values.schema.json file it follows references to additional schema files. Signed-off-by: Ben Lavery-Griffiths --- pkg/chart/common/util/jsonschema.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/chart/common/util/jsonschema.go b/pkg/chart/common/util/jsonschema.go index acd2ca100..5063c7e62 100644 --- a/pkg/chart/common/util/jsonschema.go +++ b/pkg/chart/common/util/jsonschema.go @@ -131,12 +131,12 @@ func ValidateAgainstSingleSchema(values common.Values, schemaJSON []byte) (reter compiler := jsonschema.NewCompiler() compiler.UseLoader(loader) - err = compiler.AddResource("file:///values.schema.json", schema) + err = compiler.AddResource("./values.schema.json", schema) if err != nil { return err } - validator, err := compiler.Compile("file:///values.schema.json") + validator, err := compiler.Compile("./values.schema.json") if err != nil { return err } @@ -165,7 +165,7 @@ 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") + errStr = strings.TrimPrefix(errStr, "jsonschema validation failed with './values.schema.json#'\n") // The extra new line is needed for when there are sub-charts. return errStr + "\n"