From 234a28df48bf68d60ea51e6e91d1d53b1825d84c Mon Sep 17 00:00:00 2001 From: Brahm Lower Date: Wed, 4 Feb 2026 08:01:40 -0800 Subject: [PATCH] fix: yaml v4 update broke yaml error handling --- pkg/schema/comments/error.go | 2 +- pkg/schema/comments/error_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/schema/comments/error.go b/pkg/schema/comments/error.go index 37dfa6d..6907e76 100644 --- a/pkg/schema/comments/error.go +++ b/pkg/schema/comments/error.go @@ -36,7 +36,7 @@ func (e *CommentError) Render() string { } // update yaml error with adjusted line number - if yamlErr, ok := e.Err.(*yaml.TypeError); ok { + if yamlErr, ok := e.Err.(*yaml.LoadErrors); ok { for _, unmarshalErr := range yamlErr.Errors { // UnmarshalErrors report line number as 1-indexed unmarshalErr.Line = displayFile.Lines()[unmarshalErr.Line-1].LineNum diff --git a/pkg/schema/comments/error_test.go b/pkg/schema/comments/error_test.go index 33559c6..5ffcc9d 100644 --- a/pkg/schema/comments/error_test.go +++ b/pkg/schema/comments/error_test.go @@ -145,9 +145,9 @@ func TestCommentError_Render_WithYamlTypeError(t *testing.T) { HeadComment: "# comment line 1\n# comment line 2", } - // Create a yaml.TypeError - yamlErr := &yaml.TypeError{ - Errors: []*yaml.UnmarshalError{ + // Create a yaml.LoadError + yamlErr := &yaml.LoadErrors{ + Errors: []*yaml.LoadError{ { Line: 1, // This is relative to the comment block Err: errors.New("cannot unmarshal string into int"),