Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

dag.put - Cannot read property 'cid' of undefined #1479

Closed
alanshaw opened this issue Jul 29, 2018 · 1 comment · Fixed by #1480
Closed

dag.put - Cannot read property 'cid' of undefined #1479

alanshaw opened this issue Jul 29, 2018 · 1 comment · Fixed by #1480
Labels
exp/novice Someone with a little familiarity can pick up kind/bug A bug in existing code (including security flaws) P3 Low: Not priority right now

Comments

@alanshaw
Copy link
Member

Tracking issue for bug reported here: d299ed7#r29874058

await ipfs.dag.put(obj) // Error: Cannot read property 'cid' of undefined

Assumes options object exists.

Tests added here: ipfs-inactive/interface-js-ipfs-core#338 already

@alanshaw alanshaw added kind/bug A bug in existing code (including security flaws) status/in-progress In progress exp/novice Someone with a little familiarity can pick up P3 Low: Not priority right now labels Jul 29, 2018
alanshaw referenced this issue Jul 29, 2018
* fix(core/components/dag): make options in `put` API optional

The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes #1395

License: MIT
Signed-off-by: Pascal Precht <[email protected]>

* chore: update interface-ipfs-core dependency

License: MIT
Signed-off-by: Alan Shaw <[email protected]>
@negamaxi
Copy link
Contributor

negamaxi commented Jul 30, 2018

@alanshaw ok, I've investigated a bit and found out that error actually was caused by this:

let dagParams
// ...
await ipfs.dag.put(obj, dagParams)

Just put(obj) works fine.

@ghost ghost removed the status/in-progress In progress label Aug 8, 2018
alanshaw pushed a commit that referenced this issue Aug 8, 2018
* fix(dag): check dag.put options for plain object

fixes #1479

* fix(dag): check for undefined options value

* fix: increase timeout for pin after hook

License: MIT
Signed-off-by: Alan Shaw <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exp/novice Someone with a little familiarity can pick up kind/bug A bug in existing code (including security flaws) P3 Low: Not priority right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants