Error on send message via API
teruteru128 opened this issue · 22 comments
If you send a message to an address registered in the address book via API, an error will be returned.
2021-12-11 02:50:58,436 - ERROR - too many values to unpack
Traceback (most recent call last):
File "api.py", line 1514, in _dispatch
File "api.py", line 1487, in _handle_request
File "api.py", line 1137, in HandleSendMessage
ValueError: too many values to unpack
OS: Windows 10 21H1
PyBitmessage: 0.6.3.2 20211207
Could I see your code?
The first thing you can prepare is written in C, is that okay?
The first thing you can prepare is written in C, is that okay?
I'm not afraid (;
The line number of your traceback seems to point to decoding of base64 in subject argument
Hmm ... should I submit something made with python?
I think it's probably not difficult because it depends on whether there is a corresponding record in the address book using the XML-RPC API.
The line number of your traceback seems to point to decoding of base64 in subject argument
Oh, I see it's really about the label: https://github.com/Bitmessage/PyBitmessage/blob/v0.6/src/api.py#L1137
Hmm ... should I submit something made with python? I think it's probably not difficult because it depends on whether there is a corresponding record in the address book using the XML-RPC API.
Yes, if you can reproduce it in python. Don't you get this exception when using JSON-RPC? It seems not related.
Um ... I'm sorry, I'm using PyBitmessage distributed as a binary on Windows, so I can't modify the source code and test it right away.
However, the indication of removing the comma seems correct.
The source code has been updated. I think this makes it easier to see.
https://github.com/teruteru128/study/blob/9324573/src/bmsendmsg.c
https://github.com/teruteru128/libstudy/blob/d3475a2/src/bmapi.c#L88-L126
The ValueError is confusing me. However I was able to reproduce a scaled down version of the exception, maybe it will help (I don't have more time at the moment to look into it).
>>> r = [[[0, 0, 0], 0, 0]]
>>> toLabel, = r[0][0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: too many values to unpack
If I had to take a wild guess, I would say there are duplicate records in the address book, or the label column is stored in an unusual storage type (a BLOB instead of a TEXT, maybe). This type of problem should still be handled better in PyBM though.
Try bytes:
toLabel = b'test'
Yep looks like you're right:
>>> r = [[b'sldfkjas']]
>>> toLabel, = r[0][0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: too many values to unpack
Well the same happens with a string, makes sense for python2. So the comma shouldn't be there, it's a bug.
OK, so I have to write a test and merge the fix or at least build a new continuous release. Maybe tomorrow.
The test is written, the fix is already available on my continuous release page. Note, it's built in slightly different way than official ones.
OK, so I have to write a test and merge the fix or at least build a new continuous release. Maybe tomorrow.
The test is written, the fix is already available on my continuous release page. Note, it's built in slightly different way than official ones.
I was able to confirm that the problem was fixed! 👍
The test is written, the fix is already available on my continuous release page. Note, it's built in slightly different way than official ones.
I was able to confirm that the problem was fixed! +1
So, let's wait for merging of #1899. Thank you for report! It's been a while since the API refactoring.
OK, so I have to write a test and merge the fix or at least build a new continuous release. Maybe tomorrow.
The test is written, the fix is already available on my continuous release page. Note, it's built in slightly different way than official ones.
Hi, I've tried this unofficial release, but it doesn't seem that jsonapi is available. Should I create a new issue?
2021-12-13 15:39:08,928 - WARNING - defusedxml not available, only use API on a secure, closed network.
2021-12-13 15:39:08,928 - WARNING - jsonrpclib not available, failing back to XML-RPC
OK, so I have to write a test and merge the fix or at least build a new continuous release. Maybe tomorrow.
The test is written, the fix is already available on my continuous release page. Note, it's built in slightly different way than official ones.
Hi, I've tried this unofficial release, but it doesn't seem that jsonapi is available. Should I create a new issue?
2021-12-13 15:39:08,928 - WARNING - defusedxml not available, only use API on a secure, closed network. 2021-12-13 15:39:08,928 - WARNING - jsonrpclib not available, failing back to XML-RPC
I have confirmed that the same issue occurs with the officially released snapshot binaries.
https://download.bitmessage.org/snapshots/20211207/
Hi, I've tried this unofficial release, but it doesn't seem that jsonapi is available. Should I create a new issue?
2021-12-13 15:39:08,928 - WARNING - defusedxml not available, only use API on a secure, closed network. 2021-12-13 15:39:08,928 - WARNING - jsonrpclib not available, failing back to XML-RPCI have confirmed that the same issue occurs with the officially released snapshot binaries. https://download.bitmessage.org/snapshots/20211207/
Thank you I'll open a separate issue for this.