Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

/api/v0/add?progress=true - IPFS-Proxy response difference to IPFS-Api #1286

Closed
rryter opened this issue Jan 13, 2021 · 2 comments · Fixed by #1287
Closed

/api/v0/add?progress=true - IPFS-Proxy response difference to IPFS-Api #1286

rryter opened this issue Jan 13, 2021 · 2 comments · Fixed by #1287
Labels
exp/novice Someone with a little familiarity can pick up kind/bug A bug in existing code (including security flaws) P0 Critical: Tackled by core team ASAP status/in-progress In progress

Comments

@rryter
Copy link

rryter commented Jan 13, 2021

Additional information:

  • OS: Linux
  • IPFS Cluster version: v0.13.0
  • Installation method: kubernetes

Describe the bug:

✅ IPFS-Api response:

POST /api/v0/add?progress=true HTTP/1.1
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Cache-Control: no-cache
Postman-Token: 90786707-b2e4-4bcf-9012-0edd29cc6fce
Host: localhost:5001
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Type: multipart/form-data; boundary=--------------------------408756465734378283223436
Content-Length: 2572582
----------------------------408756465734378283223436
Content-Disposition: form-data; name="file"; filename="large-file.jpg"

<large-file.jpg>
----------------------------408756465734378283223436--
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
Connection: close
Content-Type: application/json
Server: go-ipfs/0.7.0
Trailer: X-Stream-Error
Vary: Origin
X-Chunked-Output: 1
Date: Wed, 13 Jan 2021 11:03:26 GMT
Transfer-Encoding: chunked
{"Name":"large-file.jpg","Bytes":262144}
{"Name":"large-file.jpg","Bytes":524288}
{"Name":"large-file.jpg","Bytes":786432}
{"Name":"large-file.jpg","Bytes":1048576}
{"Name":"large-file.jpg","Bytes":1310720}
{"Name":"large-file.jpg","Bytes":1572864}
{"Name":"large-file.jpg","Bytes":1835008}
{"Name":"large-file.jpg","Bytes":2097152}
{"Name":"large-file.jpg","Bytes":2359296}
{"Name":"large-file.jpg","Bytes":2572370}
{"Name":"large-file.jpg","Hash":"QmNsB4Cvxp4nL2Bt1irBWDBDWpmFDneQjVzDqfT3SLCjNp","Size":"2572999"}

❌ IPFS-Proxy-Api response:

POST /api/v0/add?progress=true HTTP/1.1
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Cache-Control: no-cache
Postman-Token: 477293b2-1071-4745-b435-112f8f7bf072
Host: ipfs.lukso.network:5001
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Type: multipart/form-data; boundary=--------------------------993642091441764070694351
Content-Length: 2572582
----------------------------993642091441764070694351
Content-Disposition: form-data; name="file"; filename="large-file.jpg"

<large-file.jpg>
----------------------------993642091441764070694351--
HTTP/1.1 200 OK
Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
Cache-Control: no-cache
Connection: close
Content-Type: application/json
Server: ipfs-cluster/ipfsproxy/0.13.0+git6b25d6fd3ed2348f8e8460ae1dcc0ee0ce4a255d
Trailer: X-Stream-Error
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Chunked-Output: 1
Date: Wed, 13 Jan 2021 11:03:55 GMT
Transfer-Encoding: chunked
{"Name":"","Hash":"b","Bytes":262144}
{"Name":"","Hash":"b","Bytes":524288}
{"Name":"","Hash":"b","Bytes":786432}
{"Name":"","Hash":"b","Bytes":1048576}
{"Name":"","Hash":"b","Bytes":1310720}
{"Name":"","Hash":"b","Bytes":1572864}
{"Name":"","Hash":"b","Bytes":1835008}
{"Name":"","Hash":"b","Bytes":2097152}
{"Name":"","Hash":"b","Bytes":2359296}
{"Name":"","Hash":"b","Bytes":2572370}
{"Name":"large-file.jpg","Hash":"QmNsB4Cvxp4nL2Bt1irBWDBDWpmFDneQjVzDqfT3SLCjNp","Size":"2572999"}

This results in the following error:

  ● ipfs-http-client › file upload › reports upload progress

    TypeError: Cannot read property 'toString' of undefined

      at new CID (node_modules/cids/src/index.js:86:40)
      at toCoreInterface (node_modules/ipfs-http-client/src/add-all.js:106:10)
      at addAll (node_modules/ipfs-http-client/src/add-all.js:48:15)
      at last (node_modules/it-last/index.js:15:20)
      at Object.add (node_modules/ipfs-http-client/src/add.js:18:14)

given the following test:

it("reports upload progress", (done) => {
      let ipfsClient = IpfsHttpClient(...);

      const filePath = path.resolve(__dirname, "./image/large-file.jpg");
      const file = fs.readFileSync(filePath);
      ipfsClient
        .add(
          { path: "large-file.jpg", content: file },
          {
            progress: (length) => {
              console.debug("upload progress:", length);
            },
          }
        )
        .then((result) => {
          // expect(result.size).toEqual(6809);
          expect(result.path).toEqual("large-file.jpg");
          expect(result.cid).toEqual("QmNsB4Cvxp4nL2Bt1irBWDBDWpmFDneQjVzDqfT3SLCjNp");
          done();
        });
    });

I was expecting that the response would be equal, so I assume this is a bug.

@rryter rryter added kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization labels Jan 13, 2021
@welcome
Copy link

welcome bot commented Jan 13, 2021

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment.
Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

@hsanjuan hsanjuan added exp/novice Someone with a little familiarity can pick up P0 Critical: Tackled by core team ASAP status/in-progress In progress and removed need/triage Needs initial labeling and prioritization labels Jan 13, 2021
hsanjuan added a commit that referenced this issue Jan 13, 2021
Fixes #1286. Some AddedOutput objects carry an undefined CID. This was getting
stringified as 'b', making the proxy responses include this rather than
skipping setting the field.
@hsanjuan
Copy link
Collaborator

Thank you, good catch. Will fix shortly.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
exp/novice Someone with a little familiarity can pick up kind/bug A bug in existing code (including security flaws) P0 Critical: Tackled by core team ASAP status/in-progress In progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants