fix: handle dynamic schema paths in error message trimming

The error message trimming logic was hardcoded to remove the prefix
"jsonschema validation failed with 'file:///values.schema.json#'",
which broke when we switched to using absolute paths for $ref resolution.

Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
This commit is contained in:
Benoit Tigeot 2026-02-22 14:48:07 +01:00
parent a7884d228d
commit 6a2d9a8695
No known key found for this signature in database
GPG key ID: 8E6D4FC8AEBDA62C

View file

@ -236,7 +236,12 @@ 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")
// Remove the "jsonschema validation failed with 'file://...#'" line regardless of the path
if strings.HasPrefix(errStr, "jsonschema validation failed with 'file://") {
if idx := strings.Index(errStr, "#'\n"); idx != -1 {
errStr = errStr[idx+3:] // Skip past "#'\n"
}
}
// The extra new line is needed for when there are sub-charts.
return errStr + "\n"