From 4dd91f95f79b38ae218dfc95921ae0d243394713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Mon, 2 Sep 2024 18:08:49 +0200 Subject: [PATCH] selector: workaround panic() go-ipld-prime with negative index Waiting on https://github.com/ipld/go-ipld-prime/pull/571 to be released. --- capability/policy/selector/selector.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/capability/policy/selector/selector.go b/capability/policy/selector/selector.go index 49f2f8e..1dba97e 100644 --- a/capability/policy/selector/selector.go +++ b/capability/policy/selector/selector.go @@ -183,6 +183,12 @@ func resolve(sel Selector, subject ipld.Node, at []string) (ipld.Node, []ipld.No if idx < 0 { idx = cur.Length() + idx } + if idx < 0 { + // necessary until https://github.com/ipld/go-ipld-prime/pull/571 + // after, isMissing() below will work + // TODO: remove + return nil, nil, newResolutionError(fmt.Sprintf("index out of bounds: %d", seg.Index()), at) + } n, err := cur.LookupByIndex(idx) if err != nil { if isMissing(err) {