Skip to content

Commit 9e7f8b3

Browse files
committed
jsonpath: add err check for jsonValue Iterator retrieval
There are 2 types that can return ObjectJSONType as the type: json.jsonObject or json.jsonEncoded. The latter can return not-nil error in their implementation of ObjectIter(). This commit is to add error check for this case. Release note: None
1 parent ac39c2e commit 9e7f8b3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/util/jsonpath/eval/eval.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,10 @@ func (ctx *jsonpathCtx) executeAnyItem(
267267
}
268268
}
269269
case json.ObjectJSONType:
270-
iter, _ := jsonValue.ObjectIter()
270+
iter, err := jsonValue.ObjectIter()
271+
if err != nil {
272+
return nil, errors.Wrapf(err, "getting iterator for json object")
273+
}
271274
for iter.Next() {
272275
if err := processItem(iter.Value()); err != nil {
273276
return nil, err

0 commit comments

Comments
 (0)