ipfs-core: dag.get does not return nested CID data #3957
Description
Version: ipfs-core 0.12.2
Severity:
High - The main functionality of the application does not work, API breakage, repo format breakage, etc.
Description:
We are currently upgrading to the latest versions of ipfs-related packages. We found that ipfs-core may have an issue with dag.get
.
If we put JSON-like data on an IPFS node using dag.put
, and this data contains a key that corresponds to a valid CID (nestedCID), when we get that data using dag.get
and a path to that key, the nestedCID is returned instead of the data contained at the nestedCID.
const regularContent = { test: '123' };
const cid1 = await ipfs.dag.put(regularContent);
const linkedContent = { link: cid1 };
const cid2 = await ipfs.dag.put(linkedContent);
const atPath = await ipfs.dag.get(cid2, { path: '/link' });
// expected: { test: '123' }
// received: CID(xxx)
This is not consistent with ipfs-core v0.7, where the data stored at the nestedCID is returned.
Is returning the nestedCID the desired behavior?
I also noticed that the nestedCID data is retrieved here:
js-ipfs/packages/ipfs-core/src/utils.js
Line 248 in 6178708
yield
is not called with this data. If yield is called with this data, the data is returned.
Steps to reproduce the error:
This issue is demonstrated here: https://github.com/stephhuynh18/ipfs-dag-get-issue
CC @ukstv