-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: use go-ipld-prime Path parsing rules #142
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #142 +/- ##
==========================================
+ Coverage 69.60% 69.72% +0.12%
==========================================
Files 55 54 -1
Lines 4465 4420 -45
==========================================
- Hits 3108 3082 -26
+ Misses 1203 1189 -14
+ Partials 154 149 -5
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think LGTM? I would just assume all this exit the Lassie repo to a more appropriate pasture soon.
Refactored and extracted out of Lassie Ref: filecoin-project/lassie#142
Refactored and extracted out of Lassie Ref: filecoin-project/lassie#142
Refactored and extracted out of Lassie Ref: filecoin-project/lassie#142
Yep, that wast the plan but I wanted to get agreement on the go-ipld-prime Path handling change here before I just did it over there. So I've done that now: ipfs/go-unixfsnode#45, and updated it here to use that branch. Will update to a tagged version when I get one. |
What was the reason for the change here? Were there problems parsing the path? |
497f19f
to
5cb55da
Compare
Well, indirectly it was inspired by this thread over here ipfs/boxo#198 and accounting for just how many places we manually do path splitting separate to Kubo, and they are all different. I borrowed a lot of the logic for the original Lassie pathing parsing from https://github.com/ipld/go-ipld-selector-text-lite/blob/master/parser.go - it does things with go-unixfsnode has one here: https://github.com/ipfs/go-unixfsnode/blob/ca00f89a2119380697bb8e4b10a628b7b172d97f/signaling.go#L23 but it's super relaxed, and its lack of flexibility makes it unsuitable to use (I'm not aware of anyone actually using it so that's what ipfs/go-unixfsnode#45 is for). With that you get weird things if you add a leading or trailing go-ipld-prime has a fairly mature understanding of paths, thanks to Eric's long background thinking about these things, all laid out nicely here: https://pkg.go.dev/github.com/ipld/go-ipld-prime/datamodel#Path, his approach is to be lenient in parsing but always form the right thing for IPLD traversal, it'll even turn numbers into indexes where that might be helpful for traversal (we don't currently use that because we're focused on unixfs file/dir name traversal). SO, with all of that, I figure that instead of adding yet another implementation, we should consolidate properly; hence the two steps here -- lean on go-ipld-prime for pathing, and reinforce it as the place to go for IPLD path use, and extract our UnixFS specific tooling into go-unixfsnode so it can be reused by anyone else that wants it. There's an additional step to deprecate https://github.com/ipld/go-ipld-selector-text-lite but it's not clear exactly how to do that. It's not UnixFS focused, although it is used for UnixFS, just with dag-pb pathing ('Links/19/Hash/Links/1/Hash/Links/99/Hash/Data` - yuk). I'm inclined to add a note in there suggesting people use go-unixfsnode if they can. BUT there may be a case for further consolidation of this pattern into go-ipld-prime that does all of these things and allows go-unixfsnode to piggyback it and add the unixfs semantics at the same time. |
5cb55da
to
4264dcc
Compare
I'm going to extract all of this code into go-unixfsnode so this is just a utility we use from there but it can be reused by others, I think there's a generalised useful pattern here.
This PR doesn't necessarily need to be merged because we can get a go-unixfsnode release out pretty quick, I really just want to get agreement on the changes I'm making to the way paths are parsed.
The main change here is that I'm switching from the original manual string parser and using the one in go-ipld-prime, which is more forgiving (it won't error) and some of our rules change, particularly:
/
is not necessary (although our code path should always produce one since we pluck it off the input string)/
's are ignored, sofoo/bar
is the same asfoo/////bar
.
and..
are no longer special cases for errors, they are field names and don't carry any special meaningRemoving error conditions means we don't have to handle bad paths, there are no bad paths now.