diff --git a/decode.go b/decode.go index 82915cbc..ec60fc6a 100644 --- a/decode.go +++ b/decode.go @@ -211,6 +211,9 @@ func (d *Decoder) setToOrderedMapValue(node ast.Node, m *MapSlice) error { } func (d *Decoder) setPathToCommentMap(node ast.Node) { + if node == nil { + return + } if d.toCommentMap == nil { return } diff --git a/path.go b/path.go index aaa3477a..2192086f 100644 --- a/path.go +++ b/path.go @@ -271,6 +271,9 @@ func (p *Path) FilterFile(f *ast.File) (ast.Node, error) { // FilterNode filter from node by YAMLPath. func (p *Path) FilterNode(node ast.Node) (ast.Node, error) { + if node == nil { + return nil, nil + } n, err := p.node.filter(node) if err != nil { return nil, err