go-ipld-prime icon indicating copy to clipboard operation
go-ipld-prime copied to clipboard

Selector.Interests provides no way to return "nothing"

Open Stebalien opened this issue 3 years ago • 5 comments

That is, returning an empty set from Selector.Interests() currently means "all". There's no way to say "don't explore any sub-paths".

https://github.com/ipld/go-ipld-prime/blob/4acc5447a2efc98fa91a2396c43f570299b4a782/traversal/selector/selector.go#L84-L88

Stebalien avatar Aug 25 '21 21:08 Stebalien

Hm, that sounds like a bug. You're sure an empty (rather than nil) list doesn't do what you want?

warpfork avatar Aug 25 '21 22:08 warpfork

I'm fairly sure the relevant branches are here:

https://github.com/ipld/go-ipld-prime/blob/4acc5447a2efc98fa91a2396c43f570299b4a782/traversal/walk.go#L104-L108

and that returning an empty list should jump down to here and cause "don't explore any sub-paths" as desired.

warpfork avatar Aug 25 '21 22:08 warpfork

(Also kinda weird if a selector was going to statically return nothing for interests though, isn't it?)

warpfork avatar Aug 25 '21 22:08 warpfork

Ok, no, that's horrible. An empty list and a nil list should be the same thing. This is much worse and will likely fail in very strange ways.

Stebalien avatar Aug 25 '21 22:08 Stebalien

I just read the docs.

Stebalien avatar Aug 25 '21 22:08 Stebalien