fix(serving): avoid returning a nil node in map
@@ -898,14 +898,12 @@ func d2d(d *srvpb.Document, patterns []*regexp.Regexp, nodes map[string]*cpb.Nod
continue
}
- nodes[node.Ticket] = nodeToInfo(patterns, node)
+ n := nodeToInfo(patterns, node)
if def := node.DefinitionLocation; def != nil {
- n := nodes[node.Ticket]
if n == nil {
// Add an empty NodeInfo to attach definition location even if no facts
// are requested.
n = &cpb.NodeInfo{}
- nodes[node.Ticket] = n
}
n.Definition = def.Ticket
@@ -913,6 +911,10 @@ func d2d(d *srvpb.Document, patterns []*regexp.Regexp, nodes map[string]*cpb.Nod
defs[def.Ticket] = a2a(def, false).Anchor
}
}
+
+ if n != nil {
+ nodes[node.Ticket] = n
+ }
}
return &xpb.DocumentationReply_Document{
