KnugiHK / WhatsApp-Chat-Exporter

A customizable Android and iOS/iPadOS WhatsApp database parser that will give you the history of your WhatsApp conversations in HTML and JSON. Android Backup Crypt12, Crypt14, Crypt15, and new schema supported.
https://wts.knugi.dev/
MIT License
518 stars 76 forks source link

KeyError: 1152562 Dev Branch #45

Open Stratos-Crimson opened 1 year ago

Stratos-Crimson commented 1 year ago

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 commented 1 year ago

@KnugiHK ?

KnugiHK commented 1 year ago

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

Stratos-Crimson commented 1 year ago

Yes there is.

Stratos-Crimson commented 1 year ago

It's NULL though.

KnugiHK commented 1 year ago

If it is NULL it cannot be 1152562.

Stratos-Crimson commented 1 year ago

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

Stratos-Crimson commented 1 year ago

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

KnugiHK commented 1 year ago

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

Stratos-Crimson commented 1 year ago

Then why did It error out on that?

KnugiHK commented 1 year ago

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

Stratos-Crimson commented 1 year ago

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

Stratos-Crimson commented 1 year ago

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.

KnugiHK commented 1 year ago

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.

Stratos-Crimson commented 1 year ago

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

KnugiHK commented 1 year ago

Sure.

Stratos-Crimson commented 1 year ago

Done

KnugiHK commented 1 year ago

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 commented 1 year ago

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.

Stratos-Crimson commented 1 year ago

It's persisting

Stratos-Crimson commented 1 year ago

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 commented 1 year ago

@KnugiHK ?

KnugiHK commented 1 year ago

Could you show me the output?

Stratos-Crimson commented 12 months ago

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

qosch commented 1 month ago

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

Stratos-Crimson commented 1 month ago

I will try again then.

Stratos-Crimson commented 2 weeks ago

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

Stratos-Crimson commented 2 weeks ago

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