Handle any supported IPLD codec for CAR imports
Checklist
- [X] My issue is specific & actionable.
- [X] I am not suggesting a protocol enhancement.
- [X] I have searched on the issue tracker for my issue.
Description
ipfs dag import will fail on CAR imports containing blocks with codecs other than dag-cbor, dag-pb, and raw despite kubo having support for other codecs (e.g. dag-json, cbor, json, git, dag-jose, etc.).
This seems to be due to the use of the ipld.Decode function from go-ipld-format which does not have the codecs registered in the default go-ipld-prime registry available.
Uses include:
https://github.com/ipfs/kubo/blob/9a87262627a9b28542539a2d1fcd260910e0ab84/core/commands/dag/import.go#L93 https://github.com/ipfs/kubo/blob/9a87262627a9b28542539a2d1fcd260910e0ab84/core/commands/dag/import.go#L184
Probably replacing these with go-ipld-legacy's DecodeNode function and adding some testing would be sufficient.
Whether you count this as an issue or a bug likely depends on your perspective, however it's an unexpected result emergent from the work on #7976 although it doesn't seem like much if any functionality was lost.
@schomatis : is this something you could take?
Working on this.
@aschmahmann This would be the gist of the error we need to test, rigth?
HASH=$(echo 'Hello' | ipfs add -Q)
ipfs dag get $HASH > dag.out
NEW_HASH=$(ipfs dag put --store-codec dag-json dag.out)
ipfs dag export $NEW_HASH > dag.car
ipfs dag import dag.car
# Error: unrecognized object type: 297 (0x129 dag json type)