Skip to content
New issue

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

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

Already on GitHub? # to your account

Error when importing sms #103

Closed
farzadx opened this issue Mar 11, 2023 · 16 comments
Closed

Error when importing sms #103

farzadx opened this issue Mar 11, 2023 · 16 comments
Assignees
Labels
bug Something isn't working

Comments

@farzadx
Copy link

farzadx commented Mar 11, 2023

Hi
When i import messages i get error
My phone is poco x3 pro
Android 12

Screenshot_2023-03-11-15-48-58-316_com github tmo1 sms_ie

@farzadx
Copy link
Author

farzadx commented Mar 12, 2023

logs.txt

@farzadx
Copy link
Author

farzadx commented Mar 12, 2023

@tmo1
Copy link
Owner

tmo1 commented Mar 13, 2023

Thank you - I'm looking into this.

@farzadx
Copy link
Author

farzadx commented Mar 14, 2023

Thanks . Will there be any fix ? 😢

@tmo1
Copy link
Owner

tmo1 commented Mar 15, 2023

I can't find any trace of the error message you're seeing online, but I hope I can fix the problem. I have something I'll try when I get a chance.

@tmo1 tmo1 self-assigned this Mar 15, 2023
@tmo1 tmo1 added the bug Something isn't working label Mar 15, 2023
@tmo1
Copy link
Owner

tmo1 commented Mar 21, 2023

I have been unable to reproduce the problem using the JSON file you provided on various (emulated) Android images, including an Android 12 (API 31) one - in my tests, the two SMS messages import correctly, without error. Is your Poco X3 Pro using MIUI, or something closer to stock Android, like LineageOS?

@farzadx
Copy link
Author

farzadx commented Mar 22, 2023

Miui

@tmo1
Copy link
Owner

tmo1 commented Mar 23, 2023

If the problem can't be reproduced on regular Android, there's not much I can do to troubleshoot. Just guessing from the error message (about which I can't find anything online, as above, perhaps because it's not a standard Android error message), you might try removing the "deleted": "0" lines from the JSON and seeing if that lets the improt work. If it does, I can provide a script or jq invocation that automates the process.

@farzadx
Copy link
Author

farzadx commented Mar 24, 2023

I recover my messages with other phone, ok i will try , thanks

@t-e-s-tweb
Copy link

t-e-s-tweb commented Jul 1, 2023

If the problem can't be reproduced on regular Android, there's not much I can do to troubleshoot. Just guessing from the error message (about which I can't find anything online, as above, perhaps because it's not a standard Android error message), you might try removing the "deleted": "0" lines from the JSON and seeing if that lets the improt work. If it does, I can provide a script or jq invocation that automates the process.

I had similar issue on miui 14. After I deleted "deleted 0" and "sync state 0" completely from the file on the latest beta 2.0 pre version, I was able to restore my SMS. A total of 14000+ SMS so the backup was absolutely necessary.

@tmo1
Copy link
Owner

tmo1 commented Jul 5, 2023

I had similar issue on miui 14. After I deleted "deleted 0" and "sync state 0" completely from the file on the latest beta 2.0 pre version, I was able to restore my SMS.

Thank you for the report. I plan to document this problem and solution in the README and close this issue.

FTR, removing all the deleted keys from the JSON can be done with the jq tool:

~$ jq 'del(.[].display_name)' messages-nnn.json > messages-nnn-MIUI-stripped.json

where messages-nnn.json is the name of the original JSON file, and messages-nnn-MIUI-stripped.json is a file to write the stripped JSON to.

To remove both the deleted and sync_state keys, run:

~$ jq 'del(.[] ["deleted", "sync_state"])' messages-nnn.json > messages-nnn-MIUI-stripped.json

@tmo1 tmo1 closed this as completed in d5a4904 Jul 5, 2023
@tmo1 tmo1 mentioned this issue Feb 23, 2024
@viktak
Copy link

viktak commented Nov 13, 2024

Hi and thanks for this great tool!
I got to this page as I got the same error on a MIUI device. I tried the workaround described above, but it did not work. To be honest, The command suggested above (jq 'del(.[] ["deleted", "sync_state"])' messages-nnn.json > messages-nnn-MIUI-stripped.json) errored out for me, so I had to modify it.
It worked like this for me:
cat ./messages.ndjson | jq 'del(.deleted, .sync_state)' > messages.ndjson-MIUI-stripped.json
(Just writing it here, so that you can correct me if I made a mistake I don't realize.)

The result I'm getting is a proper json file, here is an example entry:

{
  "_id": "1",
  "thread_id": "10",
  "date": "1583918765",
  "date_sent": "1583918765",
  "msg_box": "1",
  "read": "1",
  "sub": "",
  "sub_cs": "106",
  "m_type": "132",
  "ct_cls": "135",
  "locked": "0",
  "seen": "1",
  "timed": "0",
  "date_ms_part": "0",
  "marker": "0",
  "bind_id": "0",
  "mx_status": "0",
  "need_download": "0",
  "out_time": "0",
  "preview_type": "0",
  "preview_data_ts": "0",
  "sim_id": "-1",
  "block_type": "0",
  "advanced_seen": "3",
  "mx_type": "0",
  "favorite_date": "0",
  "text_only": "0",
  "__sender_address": {
    "_id": "1",
    "msg_id": "1",
    "address": "aaaaaaaaaaaaaa",
    "type": "137",
    "charset": "106"
  },
  "__recipient_addresses": [
    {
      "_id": "2",
      "msg_id": "1",
      "address": "lkjhlkjhlkj@kjhlkjhlkjh.com",
      "type": "151",
      "charset": "106"
    }
  ],
  "__parts": [
    {
      "_id": "1",
      "mid": "1",
      "seq": "0",
      "ct": "application/vnd.gsma.botmessage.v1.0+json",
      "name": "attachment",
      "chset": "106",
      "_data": "/data/user_de/0/com.android.providers.telephony/app_parts/PART_1583918766283"
    }
  ]
}

When I try to import this I get an error for pretty much everything, like this:
Screenshot_2024-11-13-09-59-52-850_com github tmo1 sms_ie

or this:
Screenshot_2024-11-13-09-59-56-970_com github tmo1 sms_ie

Since it looks like a total disaster, I suspect it has to do with the tools I use. So here is my "toolchain":

  • I do the conversion on Linux in a docker container: Debian GNU/Linux 11 (bullseye) x86_64
  • jq version: jq-1.6
  • I do the zip/unzip operation on a Windows 11 64-bit box

Any idea what could be wrong?

@tmo1
Copy link
Owner

tmo1 commented Nov 14, 2024

Any idea what could be wrong?

I think the problem is that the original jq command I gave (and your modification thereof) are emitting normal JSON, and the current v2 format requires NDJSON. Try adding the -c flag to jq.

@viktak
Copy link

viktak commented Nov 14, 2024

Thanks for the quick reply. I'll try this, but only on Tuesday, as I'm away at the moment. Will report back!

@viktak
Copy link

viktak commented Nov 15, 2024

Thank you for the quick reply. I'm away now, so can't try this until Tuesday. I will report back then.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants