carderne / signal-export

Export your Signal chats to markdown files with attachments
Other
481 stars 50 forks source link

Signal Export Failing UnicodeDecodeError / IndexError #100

Closed p4inki77er closed 8 months ago

p4inki77er commented 1 year ago

Desktop (please complete the following information):

Describe the bug The bug occurs when running the process to export the signal chats

To reproduce Steps to reproduce the behavior. Please include the exact commands tried.

  1. Docker installed and running as non-root
  2. Created new venv
  3. pip install signal-export
  4. python -m sigexport.main ~/signal-chats

Directly after that I see the following error message:

Do you have any tips on how I could solve this issue? :)

Thank you very much in advance!

$ python -m sigexport.main ~/signal-chats
Using Docker to extract data, this may take a while the first time!
Exception in thread Thread-2:
Traceback (most recent call last):
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1366, in _readerthread
    buffer.append(fh.read())
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python38-32\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 611: character maps to <undefined>
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\<username>\PycharmProjects\signal-export2\venv\lib\site-packages\sigexport\main.py:538 in  │
│ main                                                                                             │
│                                                                                                  │
│   535 │   │   if verbose:                                                                        │
│   536 │   │   │   cmd.append("--verbose")                                                        │
│   537 │   │   try:                                                                               │
│ ❱ 538 │   │   │   p = subprocess.run(cmd, capture_output=True, text=True, check=True)            │
│   539 │   │   │   docker_logs_1, data_raw, docker_logs_2 = p.stdout.split(DATA_DELIM)            │
│   540 │   │   │   data = json.loads(data_raw)                                                    │
│   541 │   │   │   if log:                                                                        │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │          chats = None                                                                        │ │
│ │            cmd = [                                                                           │ │
│ │                  │   'docker',                                                               │ │
│ │                  │   'run',                                                                  │ │
│ │                  │   '--rm',                                                                 │ │
│ │                  │   '--volume=C:\\Users\\<username>\\AppData\\Roaming\\Signal:/Signal',        │ │
│ │                  │   'carderne/sigexport:v1.6.1'                                             │ │
│ │                  ]                                                                           │ │
│ │           conf = <_io.TextIOWrapper                                                          │ │
│ │                  name='C:\\Users\\<username>\\AppData\\Roaming\\Signal\\config.json' mode='r'   │ │
│ │                  encoding='cp1252'>                                                          │ │
│ │        db_file = WindowsPath('C:/Users/<username>/AppData/Roaming/Signal/sql/db.sqlite')        │ │
│ │           dest = WindowsPath('C:/Users/<username>/signal-chats')                                │ │
│ │   docker_image = 'carderne/sigexport:v1.6.1'                                                 │ │
│ │ docker_version = '1.6.1'                                                                     │ │
│ │           html = True                                                                        │ │
│ │  include_empty = False                                                                       │ │
│ │            key = '<redacted>'          │ │
│ │     list_chats = False                                                                       │ │
│ │         manual = False                                                                       │ │
│ │            old = None                                                                        │ │
│ │      overwrite = False                                                                       │ │
│ │       paginate = 100                                                                         │ │
│ │     print_data = False                                                                       │ │
│ │          quote = True                                                                        │ │
│ │         source = WindowsPath('C:/Users/<username>/AppData/Roaming/Signal/config.json')          │ │
│ │            src = WindowsPath('C:/Users/<username>/AppData/Roaming/Signal')                      │ │
│ │     use_docker = True                                                                        │ │
│ │        verbose = False                                                                       │ │
│ │        version = None                                                                        │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ C:\Users\<username>\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py:491 in run          │
│                                                                                                  │
│    488 │                                                                                         │
│    489 │   with Popen(*popenargs, **kwargs) as process:                                          │
│    490 │   │   try:                                                                              │
│ ❱  491 │   │   │   stdout, stderr = process.communicate(input, timeout=timeout)                  │
│    492 │   │   except TimeoutExpired as exc:                                                     │
│    493 │   │   │   process.kill()                                                                │
│    494 │   │   │   if _mswindows:                                                                │
│                                                                                                  │
│ ╭───────────────────────────────────────── locals ──────────────────────────────────────────╮    │
│ │ capture_output = True                                                                     │    │
│ │          check = True                                                                     │    │
│ │          input = None                                                                     │    │
│ │         kwargs = {'text': True, 'stdout': -1, 'stderr': -1}                               │    │
│ │      popenargs = (                                                                        │    │
│ │                  │   [                                                                    │    │
│ │                  │   │   'docker',                                                        │    │
│ │                  │   │   'run',                                                           │    │
│ │                  │   │   '--rm',                                                          │    │
│ │                  │   │   '--volume=C:\\Users\\<username>\\AppData\\Roaming\\Signal:/Signal', │    │
│ │                  │   │   'carderne/sigexport:v1.6.1'                                      │    │
│ │                  │   ],                                                                   │    │
│ │                  )                                                                        │    │
│ │        process = <subprocess.Popen object at <redacted>>                                  │    │
│                                                                                                  │
│ ╭──────────────────────── locals ────────────────────────╮                                       │
│ │      endtime = None                                    │                                       │
│ │        input = None                                    │                                       │
│ │ orig_timeout = None                                    │                                       │
│ │         self = <subprocess.Popen object at <redacted>> │                                       │
│ │       stderr = []                                      │                                       │
│ │       stdout = ''                                      │                                       │
│ ╰────────────────────────────────────────────────────────╯                                       │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
IndexError: list index out of range
ConstantineK commented 1 year ago

I am reproduce this issue - install, run exporet the first time - UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 2258: character maps to <undefined>

Jo-Karl commented 10 months ago

Hi, many thanks for the package. I am getting the same error. Is there a work-around for it?

geri777 commented 9 months ago

Same error here.

ConstantineK commented 9 months ago

btw because this was dead I made my own simple cli exporter https://github.com/ConstantineK/export-signal-desktop-to-json - only built it on windows right now but I imagine it will build in any environment you can get openssl installed on.

magnusstubman commented 9 months ago

Any updates?

carderne commented 9 months ago

Hi all, sorry I haven't had much time for this. I've just pushed https://github.com/carderne/signal-export/commit/fa69cd34d3f0cd3ce260ac737b843a4607b264a5 which should fix this.

Please upgrade to the latest version by running pip install --upgrade signal-export.

Would be great if anyone can report back that this is fixed, as I don't have a Windows machine to reproduce.

magnusstubman commented 9 months ago

@carderne Thanks for pushing a change! But I'm afraid there's still errors:

PS C:\Users\user\Desktop> sigexport ~/signal-chats
Using Docker to extract data, this may take a while the first time!
Docker process failed, see logs below:
Command '['docker', 'run', '--rm', '--volume=C:\\Users\\user\\AppData\\Roaming\\Signal:/Signal', 'carderne/sigexport:v1.7.0']' returned non-zero exit status 1.

PS C:\Users\user\Desktop> python -m sigexport.main ~/signal-chats
Using Docker to extract data, this may take a while the first time!
Docker process failed, see logs below:
Command '['docker', 'run', '--rm', '--volume=C:\\Users\\user\\AppData\\Roaming\\Signal:/Signal', 'carderne/sigexport:v1.7.0']' returned non-zero exit status 1.

PS C:\Users\user\Desktop> docker run --rm --volume=C:\Users\user\AppData\Roaming\Signal:/Signal carderne/sigexport:v1.7.0
Using Docker to extract data, this may take a while the first time!
Error: using Docker method, but is Docker installed?
Try running this from the command line:
docker run hello-world

PS C:\Users\user\Desktop> docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:ac69084025c660510933cca701f615283cdbb3aa0963188770b54c31c8962493
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

PS C:\Users\user\Desktop>
carderne commented 9 months ago

Damn sorry please install latest and try again!

Fix: https://github.com/carderne/signal-export/commit/54af3f5287d1751e10fd3f5b64b3485d97c43f61

carderne commented 8 months ago

I'm going to assume this is now fixed. Please re-open if that's not the case.