storj-archived / storj-python-sdk

Deprecated. A Python SDK for the Storj API.
https://storj.io
MIT License
23 stars 19 forks source link

Passing `shard.tree` as a JSON field to the bridge throws an exception #41

Closed Miskerest closed 5 years ago

Miskerest commented 7 years ago

shard.tree is a MerkleTree object that is pushed to the bridge in frame_add_shard. This throws an exception every time, because MerkleTree objects are not serializable.

eg:

TypeError: <class 'storj.model.MerkleTree'> 

<snip>

 is not JSON serializable

I'll try to resolve this, it looks like it should be fixable by changing the encoding, perhaps. The pertinent line is here: https://github.com/Storj/storj-python-sdk/blob/master/storj/http.py#L348

as well as Line 354, where data is assigned to json and then passed to the request function.

I think changing L348 to 'tree': shard.tree.leaves, might fix the issue, but then the server returns a bad response.

I haven't had much time to look at it, but it looks like the encoding of json is incorrect when sent to the bridge, as this is the server response:

Error: Cast to ObjectId failed for value &quot;{u&#39;locked&#39;: False, u&#39;created&#39;:
 u&#39;2016-10-29T06:03:57.587Z&#39;, u&#39;shards&#39;: [], u&#39;user&#39;: 
u&#39;misker@protonmail.com&#39;, u&#39;id&#39;: u&#39;58143bcd66926e7123a72686&#39;, 
u&#39;size&#39;: 0}&quot; at path &quot;_id&quot;
prestwich commented 7 years ago

We should probably not try to push shard.tree. Instead, we should implement the getPutblicRecord function from the JS client. It pulls the parts of the tree that should be sent to the Bridge, and we can have it handle serialization if necessary.

RichardLitt commented 5 years ago

👋 Hey! Thanks for this contribution. Apologies for the delay in responding!

We've decided to rearchitect Storj, so that we can scale better. You can read more about this decision here. This means that we are entirely focused on v3 at the moment, in the storj/storj repository. Our white paper for v3 is coming very, very soon - follow along on the blog and in our Rocketchat.

As this repository is part of the v2 network, we're no longer maintaining this repository. I am going to close this for now. If you have any questions, I encourage you to jump on Rocketchat and ask them there. Thanks!