Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add endpoints output: improvements and compliance #569

Merged
merged 1 commit into from Oct 5, 2018

Conversation

hsanjuan
Copy link
Collaborator

@hsanjuan hsanjuan commented Oct 3, 2018

This straigthens some mistakes with the outputs of the /add endpoints.

Currently, we had exactly the same output format which:

  • was not exactly the ipfs API output format but was sort of similar
  • made some weird concessions to be compatible (like having a string-type "size")
  • was not aligned with Cluster API conventions (lowercase keys)

This corrects all this:

  • The Cluster API /add output format now uses the right types and lowercase keys.
  • Hash is now Cid, because the field carries a Cid.
  • We copy error handling with request trailers from IPFS, and avoid carrying the
    errors in the output objects.
  • The proxy now returns exactly the types as ipfs would
  • We add the X-Chunked-Output: 1 header, which is custom and redundant, but
    otherwise breaks js-ipfs-api integrations with the /add endpoint.

Fixes: ipfs/ipfs-companion#600

License: MIT
Signed-off-by: Hector Sanjuan code@hector.link

@hsanjuan hsanjuan self-assigned this Oct 3, 2018
@ghost ghost added the status/in-progress In progress label Oct 3, 2018
@hsanjuan hsanjuan added need/review Needs a review and removed status/in-progress In progress labels Oct 3, 2018
@coveralls
Copy link

coveralls commented Oct 3, 2018

Coverage Status

Coverage increased (+0.2%) to 65.369% when pulling b6306a6 on fix/add-output-format into 3e11445 on master.

@@ -390,9 +389,9 @@ func outputDagnode(out chan *api.AddedOutput, name string, dn ipld.Node) error {
}

out <- &api.AddedOutput{
Hash: dn.Cid().String(),
Cid: dn.Cid().String(),
Copy link
Contributor

@lidel lidel Oct 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this change will require update (PR) to js-ipfs-api, which still expects Hash in file-result-stream-converter.js#L32 and L38 (it should try Hash and if missing use Cid)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey, this only affects the Cluster API /add. The IPFS Proxy /add output will be fully compatible with the ipfs output format.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I get it now, thanks for explanation!

This straigthens some mistakes with the outputs of the /add endpoints.

Currently, we had exactly the same output format which:

* was not exactly the ipfs API output format but was sort of similar
* made some weird concessions to be compatible (like having a string-type "size")
* was not aligned with Cluster API conventions (lowercase keys)

This corrects all this:

* The Cluster API /add output format now uses the right types and lowercase keys.
* `Hash` is now `Cid`, because the field carries a Cid.
* We copy error handling with request trailers from IPFS, and avoid carrying the
  errors in the output objects.
* The proxy now returns exactly the types as ipfs would
* We add the X-Chunked-Output: 1 header, which is custom and redundant, but
otherwise breaks js-ipfs-api integrations with the /add endpoint.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
@ghost ghost added the status/in-progress In progress label Oct 3, 2018
@hsanjuan hsanjuan mentioned this pull request Oct 4, 2018
@hsanjuan hsanjuan merged commit f65349e into master Oct 5, 2018
@hsanjuan hsanjuan deleted the fix/add-output-format branch October 5, 2018 09:45
@ghost ghost removed the status/in-progress In progress label Oct 5, 2018
@hsanjuan hsanjuan mentioned this pull request Oct 18, 2018
25 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/review Needs a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants