From e6f360facd69d30da24e2ee89979dfc81c1068f3 Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Fri, 14 Jun 2024 01:53:01 +1000 Subject: [PATCH] fix: only add valid nodes to verb children (#1760) fixes #1751 We were hitting the above issue because we were trying to traverse the schema tree to implicitly export nodes, but were encountering a verb which added nil values into its children slice. --- backend/schema/verb.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/backend/schema/verb.go b/backend/schema/verb.go index 36edb8afd4..bfa3ebd462 100644 --- a/backend/schema/verb.go +++ b/backend/schema/verb.go @@ -62,11 +62,15 @@ func (v *Verb) Position() Position { return v.Pos } func (v *Verb) schemaDecl() {} func (v *Verb) schemaSymbol() {} func (v *Verb) schemaChildren() []Node { - children := make([]Node, 2+len(v.Metadata)) - children[0] = v.Request - children[1] = v.Response - for i, c := range v.Metadata { - children[i+2] = c + children := []Node{} + if v.Request != nil { + children = append(children, v.Request) + } + if v.Response != nil { + children = append(children, v.Response) + } + for _, c := range v.Metadata { + children = append(children, c) } return children }