Skip to content
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

car get-dag gives no decoder registered for multicodec code 120 (0x78) #568

Open
Warbo opened this issue Mar 12, 2025 · 1 comment
Open

Comments

@Warbo
Copy link

Warbo commented Mar 12, 2025

I can't seem to extract git-raw DAGs.

For example, if we add a Git repo to Kubo:

$ git init --quiet
$ mkdir -p foo/bar
$ echo hello > foo/bar/baz
$ git add foo/bar/baz 
$ git commit -m "Hi"
[master (root-commit) 4a8cc80] Hi
 1 file changed, 1 insertion(+)
 create mode 100644 foo/bar/baz
$ echo goodbye > foo/bar/baz 
$ git add foo/bar/baz 
$ git commit -m "Bye"
[master 1c641f7] Bye
 1 file changed, 1 insertion(+), 1 deletion(-)
$ ls .git/objects/*/*
.git/objects/05/4e3e01c75de2975d1bb6e436254ecf988e650f
.git/objects/1c/641f7df8a69a99c0bb1b1a1606ff1b650c6785
.git/objects/1f/72a0a3ba198abc778252eaee11142ce80244cc
.git/objects/25/42a3b2478a94f6dd2dae1a156e618a9d8bcda8
.git/objects/4a/8cc80560cf1a1a702f7bae8ec4c37aa8de9f2b
.git/objects/53/6bdc2d8a69bddedc4472fbdb3ee346d2b230a3
.git/objects/53/9ced6ac21a843e2ff88e3dc79e6ffb6dda2cc9
.git/objects/9e/0a88cb754f425b52a72ceffa96cd758c1a53ab
.git/objects/ce/013625030ba8dba906f756967f9e9ca394464a
.git/objects/dd/7e1c6f0fefe118f0b63d9f10908c460aa317a6
$ for OBJ in .git/objects/*/*; do < "$OBJ" zlib-flate -uncompress | ipfs block put --cid-codec git-raw --mhtype sha1; done
baf4bcfafjy7adr254klv2g5w4q3cktwptchgkdy
baf4bcfa4mqpx36fgtkm4boy3dilan7y3muggpbi
baf4bcfa7okqkhoqzrk6hpass5lxbcfbm5abejta
baf4bcfbfikr3er4kst3n2lnodikw4ymktwf43ka
baf4bcfckrteakygpdinhal33v2hmjq32vdpj6ky
baf4bcfctnpoc3ctjxxpnyrds7pnt5y2g2kzdbiy
baf4bcfctttwwvqq2qq7c76eohxdz4373nxnczsi
baf4bcfe6bkemw5kpijnvfjzm575jntlvrqnfhky
baf4bcfgoae3ckaylvdn2sbxxk2lh7hu4uokemsq
baf4bcfg5pyog6d7p4empbnr5t4ijbdcgbkrrpjq

Then make a CAR for the HEAD commit (this will include ancestors, trees and blobs thanks to the git-raw codec):

$ ipfs dag export "$(printf 'f01781114%s' "$(git rev-parse HEAD)")" > HEAD.car
 0s  986 B / ? [---------------------------=-------------------------------------------------] 54.57 KiB/s 0s 
$ car inspect HEAD.car
Version: 1
Roots: baf4bcfa4mqpx36fgtkm4boy3dilan7y3muggpbi
Root blocks present in data: Yes
Block count: 10
Min / average / max block length (bytes): 13 / 68 / 239
Min / average / max CID length (bytes): 24 / 24 / 24
Block count per codec:
	git-raw: 10
CID count per multihash:
	sha1: 10

car inspect seems happy. Now let's say we want to make a smaller CAR with just the latest tree, ignoring all the history and commit info:

$ car get-dag HEAD.car "$(printf 'f01781114%s' "$(git rev-parse HEAD^{tree})")" > TREE.car

2025/03/12 00:52:58 could not choose a decoder: no decoder registered for multicodec code 120 (0x78)

It seems like the git-raw multicodec isn't supported, and I couldn't find any run-time or compile-time options to adjust the supported codecs (though I might have missed it, since I'm not familiar with Go).

@rvagg
Copy link
Member

rvagg commented Mar 12, 2025

I think https://github.com/ipfs/go-ipld-git should be compatible enough with the interfaces here to just pull in. If you want to contribute this you could open a PR to:

go get github.com/ipfs/go-ipld-git

Then put _ "github.com/ipfs/go-ipld-git" near the top of the file @

go-car/cmd/car/get.go

Lines 13 to 17 in 291de5e

_ "github.com/ipld/go-ipld-prime/codec/cbor"
_ "github.com/ipld/go-ipld-prime/codec/dagcbor"
_ "github.com/ipld/go-ipld-prime/codec/dagjson"
_ "github.com/ipld/go-ipld-prime/codec/json"
_ "github.com/ipld/go-ipld-prime/codec/raw"

Then it should work 🤞 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants