Inconsistent exceptions when adding empty byte strings
See original GitHub issueI am encountering an issue when adding strings of 0 length using add_bytes(bytes(''))
(in https://github.com/oduwsdl/ipwb/issues/485).
Replication:
> import ipfsapi
> IPFS_API = ipfsapi.Client('localhost', 5001)
> IPFS_API.add_bytes('lorem')
u'QmeHxdVgh5BVLL7S7AvjrXqum8977XcPcfyHYUkoCG624N'
> IPFS_API.add_bytes('')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/ipfsapi/utils.py", line 150, in wrapper
res = cmd(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/ipfsapi/client.py", line 2087, in add_bytes
data=body, headers=headers, **kwargs)
File "/usr/local/lib/python2.7/site-packages/ipfsapi/http.py", line 37, in wrapper
return func(self, *args, **merged)
File "/usr/local/lib/python2.7/site-packages/ipfsapi/http.py", line 170, in request
files, headers, data)
File "/usr/local/lib/python2.7/site-packages/ipfsapi/http.py", line 100, in _request
files=files, headers=headers, data=data)
File "/usr/local/lib/python2.7/site-packages/ipfsapi/http.py", line 77, in _do_request
six.raise_from(exceptions.ConnectionError(error), error)
File "/Users/machawk1/Library/Python/2.7/lib/python/site-packages/six.py", line 737, in raise_from
raise value
ipfsapi.exceptions.ConnectionError: ConnectionError: [Errno 32] Broken pipe
> IPFS_API.add_bytes(bytes(''))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/ipfsapi/utils.py", line 150, in wrapper
res = cmd(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/ipfsapi/client.py", line 2087, in add_bytes
data=body, headers=headers, **kwargs)
File "/usr/local/lib/python2.7/site-packages/ipfsapi/http.py", line 37, in wrapper
return func(self, *args, **merged)
File "/usr/local/lib/python2.7/site-packages/ipfsapi/http.py", line 170, in request
files, headers, data)
File "/usr/local/lib/python2.7/site-packages/ipfsapi/http.py", line 100, in _request
files=files, headers=headers, data=data)
File "/usr/local/lib/python2.7/site-packages/ipfsapi/http.py", line 77, in _do_request
six.raise_from(exceptions.ConnectionError(error), error)
File "/Users/machawk1/Library/Python/2.7/lib/python/site-packages/six.py", line 737, in raise_from
raise value
ipfsapi.exceptions.ConnectionError: ConnectionError: [Errno 32] Broken pipe
>>>
…but sometimes from this same line with the same empty string I get:
> IPFS_API.add_bytes(bytes(''))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/ipfsapi/utils.py", line 151, in wrapper
return res[self.field]
TypeError: list indices must be integers, not str
Is it in violation to add an empty string “as bytes” to IPFS using add_bytes()
? Any clue why I would be getting multiple errors from the same line (replicable in interactive Python, too)?
ipfsapi 0.4.3 (originally experienced in 0.4.2a)
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Inconsistent treatment of empty strings vs. empty bytes · Issue #1218 ...
An application I am making needs to be able to receive bytes fields that are set to the empty buffer. I have generally...
Read more >Should I Throw ArgumentNullException if a string is blank?
My question is, is it okay to throw an ArgumentNullException even if the string is equal to string.Empty? Because technically it isn't null....
Read more >Inserting Byte[] data into SqlDataSource - Second Posting
I am trying to insert an image into database using SqlDataSource but I am getting an error saying can not convert Byte[] to...
Read more >Resolve "GENERIC_INTERNAL_ERROR" when querying ...
GENERIC_INTERNAL_ERROR: Value exceeds MAX_BYTE: You might see this exception when the source data column has a numeric value exceeding the ...
Read more >Backward Incompatible Changes - Manual - PHP
Unexpected characters in source files (such as NUL bytes outside of strings) will now result in a ParseError exception instead of a compile...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Turns out it’s actually a bug with go-IPFS: https://github.com/ipfs/go-ipfs/issues/5168 I’ll be pushing a mitigation soon.
I can confirm that it is working fine with go-IPFS v0.4.18. This ticket can perhaps be closed now.