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"),