tgalal / yowsup

The WhatsApp lib
GNU General Public License v3.0
7.08k stars 2.23k forks source link

AttributeError: 'NoneType' object has no attribute 'getData' #880

Closed plandol closed 5 years ago

plandol commented 9 years ago

I've got a fatal "AttributeError: 'NoneType' object has no attribute 'getData'" when receiving a decrypted message. Here is the output:

DEBUG:yowsup.layers.logger.layer:rx:
<message from="49157xxxxxxxx@s.whatsapp.net" notify="Marc" offline="0" type="text" id="1434552703-1" t="1434625418">
<enc type="pkmsg" v="2">
���!q�V�a�8�>▒��$�q��gS��a�
                           3��6▒!F�h�Rr�q��~ӂ&c
��(�Y^x%=�fJOO"B3
!R�t>("�E�JګԆ�V�,��/ƫa�
                       �̶b!▒"�▒����G▒��1�QLYv"�c��(����0
HEX:330887ddc2051221057113fa56a70161a538f63e1ac519bb24f21571f1a16753a4e161c90c33ffa5361a210519469968fc075272df7191c47ed38226630aa186288c595e78253d99664a4f4f2242330a210552ce743e28229a45ba4adaabd4869656922ccdfb102f07c6ab61b70beaccb66210211800221011e718c3f5e88d471898b931e6510f4c597622cb630f91b5289da89ff6063000
</enc>
</message>

Traceback (most recent call last):
  File "run.py", line 35, in <module>
    stack.loop() #this is the program mainloop
  File "/usr/lib/python2.7/site-packages/yowsup/stacks/yowstack.py", line 175, in loop
    asyncore.loop(*args, **kwargs)
  File "/usr/lib64/python2.7/asyncore.py", line 216, in loop
    poll_fun(timeout, map)
  File "/usr/lib64/python2.7/asyncore.py", line 156, in poll
    read(obj)
  File "/usr/lib64/python2.7/asyncore.py", line 87, in read
    obj.handle_error()
  File "/usr/lib64/python2.7/asyncore.py", line 83, in read
    obj.handle_read_event()
  File "/usr/lib64/python2.7/asyncore.py", line 449, in handle_read_event
    self.handle_read()
  File "/usr/lib/python2.7/site-packages/yowsup/layers/network/layer.py", line 72, in handle_read
    self.receive(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/network/layer.py", line 79, in receive
    self.toUpper(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/__init__.py", line 55, in toUpper
    self.__upper.receive(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/stanzaregulator/layer.py", line 28, in receive
    self.processReceived()
  File "/usr/lib/python2.7/site-packages/yowsup/layers/stanzaregulator/layer.py", line 51, in processReceived
    self.processReceived()
  File "/usr/lib/python2.7/site-packages/yowsup/layers/stanzaregulator/layer.py", line 51, in processReceived
    self.processReceived()
  File "/usr/lib/python2.7/site-packages/yowsup/layers/stanzaregulator/layer.py", line 48, in processReceived
    self.toUpper(oneMessageData)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/__init__.py", line 55, in toUpper
    self.__upper.receive(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/auth/layer_crypt.py", line 63, in receive
    self.toUpper(payload)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/__init__.py", line 55, in toUpper
    self.__upper.receive(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/coder/layer.py", line 35, in receive
    self.toUpper(node)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/__init__.py", line 55, in toUpper
    self.__upper.receive(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/logger/layer.py", line 14, in receive
    self.toUpper(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/__init__.py", line 55, in toUpper
    self.__upper.receive(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/__init__.py", line 160, in receive
    s.receive(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/__init__.py", line 101, in receive
    recv(node)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/protocol_messages/layer.py", line 20, in recvMessageStanza
    entity = TextMessageProtocolEntity.fromProtocolTreeNode(node)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/protocol_messages/protocolentities/message_text.py", line 38, in fromProtocolTreeNode
    entity.setBody(node.getChild("body").getData())
AttributeError: 'NoneType' object has no attribute 'getData'

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

plandol commented 9 years ago

I got myself further a step by including the YowAxolotlLayer in the stack. But now I get a new error message.

Traceback (most recent call last):
  File "./run.py", line 39, in <module>
    stack.loop() #this is the program mainloop
  File "/usr/lib/python2.7/site-packages/yowsup/stacks/yowstack.py", line 175, in loop
    asyncore.loop(*args, **kwargs)
  File "/usr/lib64/python2.7/asyncore.py", line 216, in loop
    poll_fun(timeout, map)
  File "/usr/lib64/python2.7/asyncore.py", line 156, in poll
    read(obj)
  File "/usr/lib64/python2.7/asyncore.py", line 87, in read
    obj.handle_error()
  File "/usr/lib64/python2.7/asyncore.py", line 83, in read
    obj.handle_read_event()
  File "/usr/lib64/python2.7/asyncore.py", line 449, in handle_read_event
    self.handle_read()
  File "/usr/lib/python2.7/site-packages/yowsup/layers/network/layer.py", line 72, in handle_read
    self.receive(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/network/layer.py", line 79, in receive
    self.toUpper(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/__init__.py", line 55, in toUpper
    self.__upper.receive(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/stanzaregulator/layer.py", line 28, in receive
    self.processReceived()
  File "/usr/lib/python2.7/site-packages/yowsup/layers/stanzaregulator/layer.py", line 48, in processReceived
    self.toUpper(oneMessageData)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/__init__.py", line 55, in toUpper
    self.__upper.receive(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/auth/layer_crypt.py", line 63, in receive
    self.toUpper(payload)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/__init__.py", line 55, in toUpper
    self.__upper.receive(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/coder/layer.py", line 35, in receive
    self.toUpper(node)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/__init__.py", line 55, in toUpper
    self.__upper.receive(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/logger/layer.py", line 14, in receive
    self.toUpper(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/__init__.py", line 55, in toUpper
    self.__upper.receive(data)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/axolotl/layer.py", line 99, in receive
    self.onMessage(protocolTreeNode)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/axolotl/layer.py", line 117, in onMessage
    self.handleEncMessage(protocolTreeNode)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/axolotl/layer.py", line 173, in handleEncMessage
    self.handlePreKeyWhisperMessage(node)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/axolotl/layer.py", line 184, in handlePreKeyWhisperMessage
    plaintext = sessionCipher.decryptPkmsg(preKeyWhisperMessage)
  File "/usr/lib/python2.7/site-packages/axolotl/sessioncipher.py", line 91, in decryptPkmsg
    unsignedPreKeyId = self.sessionBuilder.process(sessionRecord, ciphertext)
  File "/usr/lib/python2.7/site-packages/axolotl/sessionbuilder.py", line 43, in process
    unsignedPreKeyId = self.processV3(sessionRecord, message)
  File "/usr/lib/python2.7/site-packages/axolotl/sessionbuilder.py", line 104, in processV3
    ourSignedPreKey = self.signedPreKeyStore.loadSignedPreKey(message.getSignedPreKeyId()).getKeyPair()
  File "/usr/lib/python2.7/site-packages/yowsup/layers/axolotl/store/sqlite/liteaxolotlstore.py", line 65, in loadSignedPreKey
    return self.signedPreKeyStore.loadSignedPreKey(signedPreKeyId)
  File "/usr/lib/python2.7/site-packages/yowsup/layers/axolotl/store/sqlite/litesignedprekeystore.py", line 21, in loadSignedPreKey
    raise Exception("No such signedprekeyrecord! %s " % signedPreKeyId)
Exception: No such signedprekeyrecord! 0 

I tried sending a message (as proposed in Issue https://github.com/tgalal/yowsup/issues/869) but I had no luck: the error persists.

Any Hints?

abhiramnarla commented 9 years ago

Is the error still there?

plandol commented 9 years ago

I don't know. I didn't receive any crypted Messages any more. Sorry.

I presume, there was an error in key exchange. Probably the message was sent with an old key (from a different machine). Maybe I should have told the new public key to the sender, but I don't know how to implement that function.

Best regards

idigevian commented 9 years ago

I am getting the same error and have created the following ticket: https://github.com/tgalal/yowsup/issues/1103

One observation i have is, if you create a group, this problem of -> "'NoneType' object has no attribute 'getData'" doesn't come up.

impulse200 commented 8 years ago

Hello. I'm not sure if I am hitting the same issue. At least error stack and message are quite similar. Any way to work around this?

DEBUG:yowsup.layers.logger.layer:rx:
<message from="79151854204@s.whatsapp.net" notify="sergey a" offline="3" type="text" id="84B5C3DDE9EBBB555B0" t="1452690076">
<enc type="pkmsg" v="1">
Ï=!G}>i7/R!&iT"B3
!rue)VS"hE
HEX:3308c38f3d122105477d3e6916add67aab9485e95116a14ce62d37b61bc7071ebed5eb642f5218161a2105e527574c9651a1a926fe60f242fc266bed6954a4af4165a259fc6382458ae00b2242330a2105f06c1a489685e6b3c01895807275ff21fed765061a295690db1554539cdc3832100118002210feaf39a9b905b1f06887d95743948ad512c73140320245ae28c99ba5fd0130ff9502
</enc>
</message>

Traceback (most recent call last):
  File "/usr/local/bin/yowsup-cli", line 4, in <module>
    __import__('pkg_resources').run_script('yowsup2==2.4.48', 'yowsup-cli')
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 745, in run_script

  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 1677, in run_script

  File "/usr/local/lib64/python2.6/site-packages/yowsup2-2.4.48-py2.6.egg/EGG-INFO/scripts/yowsup-cli", line 323, in <module>

  File "/usr/local/lib64/python2.6/site-packages/yowsup2-2.4.48-py2.6.egg/EGG-INFO/scripts/yowsup-cli", line 229, in process

  File "/usr/local/lib64/python2.6/site-packages/yowsup2-2.4.48-py2.6.egg/EGG-INFO/scripts/yowsup-cli", line 265, in startEcho

  File "build/bdist.linux-x86_64/egg/yowsup/demos/echoclient/stack.py", line 48, in start
  File "build/bdist.linux-x86_64/egg/yowsup/stacks/yowstack.py", line 195, in loop
  File "/usr/lib64/python2.6/asyncore.py", line 210, in loop
    poll_fun(timeout, map)
  File "/usr/lib64/python2.6/asyncore.py", line 151, in poll
    read(obj)
  File "/usr/lib64/python2.6/asyncore.py", line 82, in read
    obj.handle_error()
  File "/usr/lib64/python2.6/asyncore.py", line 78, in read
    obj.handle_read_event()
  File "/usr/lib64/python2.6/asyncore.py", line 428, in handle_read_event
    self.handle_read()
  File "build/bdist.linux-x86_64/egg/yowsup/layers/network/layer.py", line 88, in handle_read
  File "build/bdist.linux-x86_64/egg/yowsup/layers/network/layer.py", line 96, in receive
  File "build/bdist.linux-x86_64/egg/yowsup/layers/__init__.py", line 75, in toUpper

  File "build/bdist.linux-x86_64/egg/yowsup/layers/stanzaregulator/layer.py", line 29, in receive
  File "build/bdist.linux-x86_64/egg/yowsup/layers/stanzaregulator/layer.py", line 52, in processReceived
  File "build/bdist.linux-x86_64/egg/yowsup/layers/stanzaregulator/layer.py", line 52, in processReceived
  File "build/bdist.linux-x86_64/egg/yowsup/layers/stanzaregulator/layer.py", line 49, in processReceived
  File "build/bdist.linux-x86_64/egg/yowsup/layers/__init__.py", line 75, in toUpper

  File "build/bdist.linux-x86_64/egg/yowsup/layers/auth/layer_crypt.py", line 65, in receive
  File "build/bdist.linux-x86_64/egg/yowsup/layers/__init__.py", line 75, in toUpper

  File "build/bdist.linux-x86_64/egg/yowsup/layers/coder/layer.py", line 35, in receive
  File "build/bdist.linux-x86_64/egg/yowsup/layers/__init__.py", line 75, in toUpper

  File "build/bdist.linux-x86_64/egg/yowsup/layers/logger/layer.py", line 14, in receive
  File "build/bdist.linux-x86_64/egg/yowsup/layers/__init__.py", line 75, in toUpper

  File "build/bdist.linux-x86_64/egg/yowsup/layers/__init__.py", line 188, in receive

  File "build/bdist.linux-x86_64/egg/yowsup/layers/__init__.py", line 124, in receive

  File "build/bdist.linux-x86_64/egg/yowsup/layers/protocol_messages/layer.py", line 20, in recvMessageStanza
  File "build/bdist.linux-x86_64/egg/yowsup/layers/protocol_messages/protocolentities/message_text.py", line 38, in fromProtocolTreeNode
AttributeError: 'NoneType' object has no attribute 'getData'
jlmadurga commented 8 years ago

I am experiencing that error when receiving encrypted message in a stack with no axolotl layer included. Please testing with encryption enabled.

impulse200 commented 8 years ago

Hello.

If I do not turn encryption off with -M parameter to yowsup-cli then I get something like 'google.protobuf.message.DecodeError: Truncated message.' in error message.

On Wed, Jan 13, 2016 at 6:16 PM Juan Madurga notifications@github.com wrote:

I am experiencing that error when receiving encrypted message in a stack with no axolotl layer included. Please testing with encryption enabled.

— Reply to this email directly or view it on GitHub https://github.com/tgalal/yowsup/issues/880#issuecomment-171325680.

WBR, Sergey.

kartikgola commented 8 years ago

Is there any update on this ? Still getting this error with python 3.5.2 and yowsup 2.5.0

HudsonAfonso commented 7 years ago

+1