Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Error TypeError: Cannot read property 'path' of undefined #7

Closed
madan-ideas2it opened this issue Aug 2, 2018 · 10 comments
Closed

Error TypeError: Cannot read property 'path' of undefined #7

madan-ideas2it opened this issue Aug 2, 2018 · 10 comments
Labels
exp/novice Someone with a little familiarity can pick up help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) status/ready Ready to be worked

Comments

@madan-ideas2it
Copy link

This example doesnot seem to work for me, the files are not getting added to me and hence the callback after adding returns empty array instead of the files added.

The version config and lock files are getting generated in my bucket, but the actual file to be added is not getting uploaded and no error is thrown, instead it returns empty array

@madan-ideas2it
Copy link
Author

And at times it throws

Error: invalid block

@madan-ideas2it
Copy link
Author

madan-ideas2it commented Aug 3, 2018

Found the root cause:

In ipfs-repo/src/blockstore.js

We have the put method which includes:

put (block, callback) {
      if (!Block.isBlock(block)) {
        return setImmediate(() => {
          callback(new Error('invalid block'))
        })
      }

The structure of block obj will be like

Block {
_data: <Buffer 0a 15 08 02....>,
_cid:
CID {
codec: 'dag-pb',
version: 0,
multihash: <Buffer 12 20 ....> } }

And when i inspect the code inside Block.isBlock, it reads,

(obj) => !!(obj && obj[symbol]); - It is expecting a symbol key

I am not sure from where it takes this, probably inside the dist file.

But the intended code should read as,

return other && other.constructor.name === 'Block' - As per this code, the block will be valid always

Because of this, the block will always be invalidated and file upload will fail

Hence when i tried by commenting out the isBlock validation, the file upload runs through smoothly and the blocks were successfully uploaded in bucket

@jacobheun
Copy link
Contributor

Hi @madan-ideas2it, what version of node are you running this with?

@madan-ideas2it
Copy link
Author

@jacobheun v8.11.3

@jacobheun jacobheun added kind/bug A bug in existing code (including security flaws) exp/novice Someone with a little familiarity can pick up help wanted Seeking public contribution on this issue labels Aug 10, 2018
@jacobheun
Copy link
Contributor

I updated the ipfs dependencies and am getting a different error related to cid versions. I will try to make some time later next week to look at this if you aren't able to troubleshoot the issue. I imagine it's related to a recent ipfs update as I demo'd this in early July.

@madan-ideas2it
Copy link
Author

@jacobheun i troubleshooted and the issue is that wrong code is being picked up in blockstore put method as explained

@jacobheun
Copy link
Contributor

I upgraded ipfs and ipfs-repo in the example to the latest versions and got a completely different error when I tested it. For me it is failing on node startup, before attempting to upload the block. The symbol key you are seeing comes from class-is. I haven't been able to reproduce your error.

Swarm listening on /ip4/127.0.0.1/tcp/4003/ws/ipfs/QmTRGrwwmtYXNvy4msxdmByV2UJXhYtQXDvJHLwgmA1Ct8
Swarm listening on /ip4/127.0.0.1/tcp/4002/ipfs/QmTRGrwwmtYXNvy4msxdmByV2UJXhYtQXDvJHLwgmA1Ct8
Swarm listening on /ip4/192.168.178.23/tcp/4002/ipfs/QmTRGrwwmtYXNvy4msxdmByV2UJXhYtQXDvJHLwgmA1Ct8
/Users/jacobheun/git/ipfs/js-datastore-s3/examples/full-s3-repo/node_modules/aws-sdk/lib/request.js:31
            throw err;
            ^

Error: Invalid version, must be a number equal to 1 or 0
    at Function.validateCID (/Users/jacobheun/git/ipfs/js-datastore-s3/examples/full-s3-repo/node_modules/cids/src/index.js:235:13)
    at new CID (/Users/jacobheun/git/ipfs/js-datastore-s3/examples/full-s3-repo/node_modules/cids/src/index.js:105:9)
    at datastore.get (/Users/jacobheun/git/ipfs/js-datastore-s3/examples/full-s3-repo/node_modules/ipfs-mfs/src/core/utils/with-mfs-root.js:41:19)
    at Response.opts.s3.getObject (/Users/jacobheun/git/ipfs/js-datastore-s3/src/index.js:116:16)
    at Request.<anonymous> (/Users/jacobheun/git/ipfs/js-datastore-s3/examples/full-s3-repo/node_modules/aws-sdk/lib/request.js:364:18)
    at Request.callListeners (/Users/jacobheun/git/ipfs/js-datastore-s3/examples/full-s3-repo/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/Users/jacobheun/git/ipfs/js-datastore-s3/examples/full-s3-repo/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/Users/jacobheun/git/ipfs/js-datastore-s3/examples/full-s3-repo/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/Users/jacobheun/git/ipfs/js-datastore-s3/examples/full-s3-repo/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/Users/jacobheun/git/ipfs/js-datastore-s3/examples/full-s3-repo/node_modules/aws-sdk/lib/state_machine.js:14:12)

@daviddias daviddias added the status/ready Ready to be worked label Aug 25, 2018
@jacobheun
Copy link
Contributor

Related to ipfs/js-ipfs#1557

@jacobheun
Copy link
Contributor

The examples should be working in the latest version, 0.2.0. I tested against a clean s3 bucket.

@madan-ideas2it please let me know if you're still encountering an issue.

@achingbrain
Copy link
Member

Very stale. Please reopen if you're still seeing problems.

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 help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) status/ready Ready to be worked
Projects
None yet
Development

No branches or pull requests

4 participants