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 <benoit.tigeot@lifen.fr>
pull/31274/head
Benoit Tigeot 2 weeks ago
parent 25c92f5c73
commit c6fec4cb35
No known key found for this signature in database
GPG Key ID: 8E6D4FC8AEBDA62C

@ -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"

Loading…
Cancel
Save