WhatsApp-Chat-Exporter icon indicating copy to clipboard operation
WhatsApp-Chat-Exporter copied to clipboard

KeyError: 1152562 Dev Branch

Open Stratos-Crimson opened this issue 1 year ago • 27 comments

Hello, I tried to use the dev branch to export so that I could bypass the #44 issue but now I have this. I installed using pip install git+https://github.com/KnugiHK/Whatsapp-Chat-Exporter.git@dev.

Traceback (most recent call last):
  File "/home/user/.local/bin/wtsexporter", line 8, in <module>
    sys.exit(main())
  File "/home/user/.local/lib/python3.9/site-packages/Whatsapp_Chat_Exporter/__main__.py", line 241, in main
    media(db, data, args.media)
  File "/home/user/.local/lib/python3.9/site-packages/Whatsapp_Chat_Exporter/extract.py", line 439, in media
    data[content["key_remote_jid"]].messages[content["message_row_id"]].media = True
KeyError: 1152562

Stratos-Crimson avatar May 19 '23 11:05 Stratos-Crimson

@KnugiHK ?

Stratos-Crimson avatar May 26 '23 04:05 Stratos-Crimson

Can you confirm if there is a row in message table with "1152562" in _id field?

KnugiHK avatar Jun 01 '23 14:06 KnugiHK

Yes there is.

Stratos-Crimson avatar Jun 03 '23 13:06 Stratos-Crimson

It's NULL though.

Stratos-Crimson avatar Jun 03 '23 13:06 Stratos-Crimson

If it is NULL it cannot be 1152562.

KnugiHK avatar Jun 03 '23 16:06 KnugiHK

You misunderstand, there is a row with that id but the message content is NULL

Stratos-Crimson avatar Jun 04 '23 02:06 Stratos-Crimson

Perhaps message contents that are NULL should simply be ignored just like non UTF-8 weirdness?

Stratos-Crimson avatar Jun 08 '23 02:06 Stratos-Crimson

A NULL message doesn't necessarily be invalid (e.g., the row represents other metadata or media). It shouldn't be ignored.

KnugiHK avatar Jun 10 '23 17:06 KnugiHK

Then why did It error out on that?

Stratos-Crimson avatar Jun 11 '23 00:06 Stratos-Crimson

The corresponding message entry didn't get added into the chat store probably.

KnugiHK avatar Jun 11 '23 04:06 KnugiHK

So perhaps the ones that error out like this can be skipped too instead of stopping the whole process?

Stratos-Crimson avatar Jun 11 '23 15:06 Stratos-Crimson

Is there a way to detect If something didn't get added to the chat store? If so, then you could just skip ones that didn't.

Stratos-Crimson avatar Jun 15 '23 13:06 Stratos-Crimson

Could you provide me the outputs of SELECT * FROM message WHERE _id=1152562; and SELECT * FROM message_media WHERE message_row_id=1152562? I would like to further investigate the problem before I skipping it.

KnugiHK avatar Jun 15 '23 16:06 KnugiHK

Can I just send you the row again? This didn't work out well last time.

Stratos-Crimson avatar Jun 15 '23 22:06 Stratos-Crimson

Sure.

KnugiHK avatar Jun 16 '23 03:06 KnugiHK

Done

Stratos-Crimson avatar Jun 16 '23 12:06 Stratos-Crimson

I couldn't reproduce the bug after I inserted the rows you sent to me. What's the output of the following SQL?

SELECT jid.raw_string as key_remote_jid,
       message_row_id,
       file_path,
       message_url,
       mime_type,
       media_key,
       file_hash,
       thumbnail
FROM message_media
INNER JOIN message
    ON message_media.message_row_id = message._id
LEFT JOIN chat
    ON chat._id = message.chat_row_id
INNER JOIN jid
    ON jid._id = chat.jid_row_id
LEFT JOIN media_hash_thumbnail
    ON message_media.file_hash = media_hash_thumbnail.media_hash
WHERE message_row_id = 1152562 OR key_remote_jid = 1152562
ORDER BY jid.raw_string ASC

KnugiHK avatar Jun 19 '23 09:06 KnugiHK

Since 3ed269e, the invalid flag is removed, and all possible messages are included in the output. You can try to re-install and re-run the exporter from dev to see if the problem persists.

KnugiHK avatar Jun 20 '23 11:06 KnugiHK

It's persisting

Stratos-Crimson avatar Jun 21 '23 00:06 Stratos-Crimson

I got a lot of gibberish but I did get audio/mp4 with this "|" around It. The quotes weren't there, of course.

I couldn't reproduce the bug after I inserted the rows you sent to me. What's the output of the following SQL?

SELECT jid.raw_string as key_remote_jid,
       message_row_id,
       file_path,
       message_url,
       mime_type,
       media_key,
       file_hash,
       thumbnail
FROM message_media
INNER JOIN message
    ON message_media.message_row_id = message._id
LEFT JOIN chat
    ON chat._id = message.chat_row_id
INNER JOIN jid
    ON jid._id = chat.jid_row_id
LEFT JOIN media_hash_thumbnail
    ON message_media.file_hash = media_hash_thumbnail.media_hash
WHERE message_row_id = 1152562 OR key_remote_jid = 1152562
ORDER BY jid.raw_string ASC

Stratos-Crimson avatar Jun 21 '23 00:06 Stratos-Crimson

@KnugiHK ?

Stratos-Crimson avatar Jul 05 '23 03:07 Stratos-Crimson

Could you show me the output?

KnugiHK avatar Jul 07 '23 07:07 KnugiHK

Sure and sorry for taking a while. �B.�Q�i)9~�23G�|H07O6FjcvxRvp+M1OKqJyqIG5ulpIGlfYDjv6SQA8T0=|/AvdxZMCJ2RXhBpJLY2IDedZ9ZaYfsqTWmSguEZFGaC6b.enc|audio/mp4|�_A6��k#�[3+�

Stratos-Crimson avatar Jul 12 '23 07:07 Stratos-Crimson

Had the same issue with latest main branch, but dev worked.

qosch avatar May 10 '24 13:05 qosch

I will try again then.

Stratos-Crimson avatar May 16 '24 12:05 Stratos-Crimson

It didn't fix It for me. I am still getting the same error. @KnugiHK

Stratos-Crimson avatar Jun 17 '24 17:06 Stratos-Crimson

But It's telling me that the line of the program are different. I will share the full error message soon.

Stratos-Crimson avatar Jun 17 '24 17:06 Stratos-Crimson