Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS contact database not found - potential fix in description #76

Closed
achalddave opened this issue Nov 26, 2023 · 18 comments
Closed

iOS contact database not found - potential fix in description #76

achalddave opened this issue Nov 26, 2023 · 18 comments
Assignees
Labels
enhancement New feature or request ios iOS exclusive issue

Comments

@achalddave
Copy link

Thanks for this great tool! I received the following error when using this with the latest version of WhatsApp: "Contact database not found." I think the uuid(?) for the contacts db in whatsapp may have changed.

Changing this line:

CONTACT = "b8548dc30aa1030df0ce18ef08b882cf7ab5212f"

from

    CONTACT = "b8548dc30aa1030df0ce18ef08b882cf7ab5212f"

to

    CONTACT = "016df2e52e5bfaa000f98a1dbe5c40cd6dc7f657"

fixed the issue for me. I'm not sure if this is a general fix, so I'm not submitting a PR, but opening this issue in case anyone else runs into it.

@achalddave achalddave reopened this Nov 26, 2023
@achalddave achalddave changed the title contact database not found contact database not found - potential fix in description Nov 26, 2023
@KnugiHK
Copy link
Owner

KnugiHK commented Nov 27, 2023

I currently don't have access to the latest iOS WhatsApp. Once it has been confirmed, I will make changes to the code. Thanks for your report and the potential fix anyway!

@KnugiHK KnugiHK added the enhancement New feature or request label Dec 3, 2023
@KnugiHK KnugiHK self-assigned this Dec 3, 2023
@SvenHerr
Copy link

@achalddave how did you know that this is the new db ? i cant find 016df2e52e5bfaa000f98a1dbe5c40cd6dc7f657 with the version 17.2.1

@achalddave
Copy link
Author

I'm sure there's a better way, but I went to the path to my Manifest.db, which was in a path like: ~/Library/Application Support/MobileSync/Backup/<numbers>/Manifest.db, and then ran:

~ sqlite3 Manifest.db
SQLite version 3.39.5 2022-10-14 20:58:05
Enter ".help" for usage hints.
sqlite> select * from files;

This printed a bunch of tables, and I looked for one which said ContactsV2.sqlite, and copied the hash at the start of that line.

@KnugiHK
Copy link
Owner

KnugiHK commented Jan 2, 2024

I'm sure there's a better way, but I went to the path to my Manifest.db, which was in a path like: ~/Library/Application Support/MobileSync/Backup/<numbers>/Manifest.db, and then ran:

~ sqlite3 Manifest.db
SQLite version 3.39.5 2022-10-14 20:58:05
Enter ".help" for usage hints.
sqlite> select * from files;

This printed a bunch of tables, and I looked for one which said ContactsV2.sqlite, and copied the hash at the start of that line.

This is the correct way to find a file inside an iOS backup.

@SvenHerr
Copy link

SvenHerr commented Jan 3, 2024

thank you for your reply. I just looked throu all files with .sqlite and i cant find any db with contacts.

@Rerebla
Copy link

Rerebla commented Jan 9, 2024

I get the same error "Contact database not found". Running the program with the default or the suggested fix results in the same error. I couldn't find any ContactsV2 or anything containing 'contacts' related to WhatsApp (just blockedContacts.dat).

@angelbanderasudg
Copy link

@Rerebla The file with blockedContacts.dat was the only one that appeared, but it used it and worked.

After following the steps of searching it with sqlite3, the complete line is this:
4c6a43645ed0557e7ea2ebb662ef8a2c81b505b8|AppDomain-net.whatsapp.WhatsApp|Documents/blockedcontacts.dat|1|bplist00?

You only need the first part: 4c6a43645ed0557e7ea2ebb662ef8a2c81b505b8

The file to modify, like I have the installation of python in the default directory, the path is: /Users/your_username/Library/Python/3.9/lib/python/site-packages/Whatsapp_Chat_Exporter/utility.py

My WhatsApp version is 23.23.79

@roisec
Copy link

roisec commented Feb 27, 2024

@angelbanderasudg it's solved the issue but after I have another issue
Unexpected contact format: broadcast

  File "/Users//repos/iphone/lib/python3.11/site-packages/Whatsapp_Chat_Exporter/__main__.py", line 425, in main
    create_html(
  File "/Users//repos/iphone/lib/python3.11/site-packages/Whatsapp_Chat_Exporter/android_handler.py", line 753, in create_html
    safe_file_name, name = get_file_name(contact, chat)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users//repos/iphone/lib/python3.11/site-packages/Whatsapp_Chat_Exporter/utility.py", line 141, in get_file_name
    raise ValueError("Unexpected contact format: " + contact)
ValueError: Unexpected contact format: broadcast

@jpfleischer
Copy link

please merge @angelbanderasudg 's fix

@KnugiHK
Copy link
Owner

KnugiHK commented Jun 30, 2024

@angelbanderasudg it's solved the issue but after I have another issue Unexpected contact format: broadcast

  File "/Users//repos/iphone/lib/python3.11/site-packages/Whatsapp_Chat_Exporter/__main__.py", line 425, in main
    create_html(
  File "/Users//repos/iphone/lib/python3.11/site-packages/Whatsapp_Chat_Exporter/android_handler.py", line 753, in create_html
    safe_file_name, name = get_file_name(contact, chat)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users//repos/iphone/lib/python3.11/site-packages/Whatsapp_Chat_Exporter/utility.py", line 141, in get_file_name
    raise ValueError("Unexpected contact format: " + contact)
ValueError: Unexpected contact format: broadcast

I notice that your handler is for Android. Please open a separate issue for that as this issue exclusively appear in iOS.

@KnugiHK
Copy link
Owner

KnugiHK commented Jul 20, 2024

A workaround has been implemented in #106.

@KnugiHK KnugiHK changed the title contact database not found - potential fix in description iOS contact database not found - potential fix in description Sep 7, 2024
@KnugiHK
Copy link
Owner

KnugiHK commented Sep 7, 2024

Potential fix proposed in #109 (comment) by @ReclusiveEagle.

@KnugiHK KnugiHK added the ios iOS exclusive issue label Sep 7, 2024
jpfleischer added a commit to jpfleischer/WhatsApp-Chat-Exporter that referenced this issue Sep 7, 2024
@KnugiHK
Copy link
Owner

KnugiHK commented Sep 11, 2024

I currently don't have access to the latest iOS WhatsApp. Once it has been confirmed, I will make changes to the code. Thanks for your report and the potential fix anyway!

I created an iOS (17.6.1) backup with WhatsApp 2.24.17.78. I do see the ContactsV2.sqlite file. Not sure how to reproduce the issue. Any ideas?

@KnugiHK
Copy link
Owner

KnugiHK commented Sep 14, 2024

Hi @ReclusiveEagle, I took a look at your solution and it does not seem right to me.

Using any of the unique hashes assigned to anyone of your contact's chat seem to fix the issue.

For example:

0618655a1de1254eca90c229002cdea325de408d for:

0618655a1de1254eca90c229002cdea325de408dAppDomainGroup-group.net.whatsapp.WhatsApp.sharedMessage/Media/[Contacts Number]@s.whatsapp.net/0/6/06693485-42bb-4f27-844d-1c37d93c1291.opusbplist00

In utility.py, for class WhatsAppIdentifier(StrEnum): replace the hash in CONTACT = "to the unique hash from one of your contacts." and run the script again.

However, the contact file should be a SQLite database, while your solution seems to be extracting a non-SQLite file—specifically, an audio file in this case.

@jpfleischer
Copy link

for whatever reason, the hash from the audio file works. this has allowed me to use this library without throwing any errors

@KnugiHK
Copy link
Owner

KnugiHK commented Sep 14, 2024

for whatever reason, the hash from the audio file works. this has allowed me to use this library without throwing any errors

That might indeed help resolving the contact database not found error (I haven't test it), but it's not really a proper solution.

Instead, the contact database could treated as optional, if iOS backups can't guarantee its inclusion.

@KnugiHK
Copy link
Owner

KnugiHK commented Sep 14, 2024

The commit fe88f1b should allow the tool to proceed even if the database is not presented.

@KnugiHK
Copy link
Owner

KnugiHK commented Oct 24, 2024

The contact database may not be included in the iOS backup. Since there are no alternative files to replace it, the commit fe88f1b is deemed an appropriate solution. This fix was released in 0.10.5.

@KnugiHK KnugiHK closed this as completed Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ios iOS exclusive issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants