Skip to content

Decoding issue #18

@jaredforth

Description

@jaredforth

Hello,

I'm running python fs_to_json.py ../2024-08-27T13:49:35_42810/all_namespaces/all_kinds/ out where ../2024-08-27T13:49:35_42810/all_namespaces/all_kinds/ is

├── all_namespaces_all_kinds.export_metadata
├── output-0
├── output-1
├── output-10
├── output-11
├── output-12
├── output-13
├── output-14
├── output-15
├── output-16
├── output-17
├── output-18
├── output-19
├── output-2
├── output-3
├── output-4
├── output-5
├── output-6
├── output-7
├── output-8
└── output-9

1 directory, 21 files

The conversion worked for 9 files but created 12 empty JSON files. Is this a known bug and are there any tips on how to resolve?

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
                    ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
           ^^^^^^^^^^^^^^^^
  File "/Users/jaredforth/Downloads/firestore-export-json/converter/command.py", line 145, in process_file
    json.dumps(json_tree, default=serialize_json, ensure_ascii=False, indent=2)
  File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
          ^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/encoder.py", line 202, in encode
    chunks = list(chunks)
             ^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/encoder.py", line 432, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/encoder.py", line 406, in _iterencode_dict
    yield from chunks
  File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/encoder.py", line 406, in _iterencode_dict
    yield from chunks
  File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/encoder.py", line 406, in _iterencode_dict
    yield from chunks
  File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/encoder.py", line 326, in _iterencode_list
    yield from chunks
  File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/encoder.py", line 439, in _iterencode
    o = _default(o)
        ^^^^^^^^^^^
  File "/Users/jaredforth/Downloads/firestore-export-json/converter/utils.py", line 77, in serialize_json
    return str(obj)
           ^^^^^^^^
  File "/Users/jaredforth/Downloads/firestore-export-json/venv/lib/python3.12/site-packages/google/appengine/api/datastore_types.py", line 1227, in __str__
    return self.decode('utf-8')
           ^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xeb in position 24: invalid continuation byte
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/jaredforth/Downloads/firestore-export-json/fs_to_json.py", line 14, in <module>
    main()
  File "/Users/jaredforth/Downloads/firestore-export-json/fs_to_json.py", line 10, in main
    command.main(args=args)
  File "/Users/jaredforth/Downloads/firestore-export-json/converter/command.py", line 93, in main
    process_files(
  File "/Users/jaredforth/Downloads/firestore-export-json/converter/command.py", line 113, in process_files
    p.map(f, files)
  File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/pool.py", line 367, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/pool.py", line 774, in get
    raise self._value
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xeb in position 24: invalid continuation byte

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions