Skip to content
This repository was archived by the owner on Jun 23, 2024. It is now read-only.

TypeError: Object of type PosixPath is not JSON serializable #31

Closed
IzzySoft opened this issue Sep 2, 2023 · 1 comment
Closed

TypeError: Object of type PosixPath is not JSON serializable #31

IzzySoft opened this issue Sep 2, 2023 · 1 comment

Comments

@IzzySoft
Copy link

IzzySoft commented Sep 2, 2023

Another crash now that an update is available for a module:

Traceback (most recent call last):
  File "/web/ftp/repo/magisk/util/cli.py", line 26, in <module>
    sys.exit(Main.exec())
  File "/mnt/data/web/ftp/repo/magisk/util/sync/cli/Main.py", line 53, in exec
    code = cls._check_args()
  File "/mnt/data/web/ftp/repo/magisk/util/sync/cli/Main.py", line 73, in _check_args
    return cls.sync()
  File "/mnt/data/web/ftp/repo/magisk/util/sync/cli/Main.py", line 265, in sync
    sync.update(
  File "/mnt/data/web/ftp/repo/magisk/util/sync/core/Sync.py", line 134, in update
    online_module = self._update_jsons(track=track, force=force)
  File "/mnt/data/web/ftp/repo/magisk/util/sync/core/Sync.py", line 84, in _update_jsons
    track.write(track_json_file)
  File "/mnt/data/web/ftp/repo/magisk/util/sync/model/TrackJson.py", line 55, in write
    JsonIO.write(new, file)
  File "/mnt/data/web/ftp/repo/magisk/util/sync/model/JsonIO.py", line 12, in write
    json.dump(self, f, indent=2)
  File "/usr/lib/python3.8/json/__init__.py", line 179, in dump
    for chunk in iterable:
  File "/usr/lib/python3.8/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.8/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/usr/lib/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type PosixPath is not JSON serializable

Module in question would be isodrive. And the worst thing about this: the crash also destroyed the corresponding track.json, which now looks like this:

{
  "id": "isodrive",
  "update_to":

(yes, that's the entire file) Luckily I still have not set up update via cron or things would have been broken online as well. And I kept a backup from before the repo-util upgrade, so I was able to restore the track.json (with manual corrections). To help you debug, here's the full track.json:

{
  "id": "isodrive",
  "update_to": "isodrive.json",
  "license": "GPL-3.0-only",
  "source": "https://github.com/nitanmarcel/isodrive-magisk",
  "support": "https://github.com/nitanmarcel/isodrive-magisk/issues",
  "donation": "https://github.com/sponsors/nitanmarcel",
  "changelog": "",
  "added": 1690407638.719967,
  "last_update": 1690292969.0,
  "versions": 2
}

and the corresponding update.json:

{
  "id": "isodrive",
  "timestamp": 1690292969.0,
  "versions": [
    {
      "timestamp": 1690292969.0,
      "version": "1.2",
      "versionCode": 12,
      "zipUrl": "https://apt.izzysoft.de/magisk/modules/isodrive/1.2_12.zip",
      "changelog": ""
    },
    {
      "timestamp": 1693645491.0,
      "version": "2.1",
      "versionCode": 21,
      "zipUrl": "https://apt.izzysoft.de/magisk/modules/isodrive/2.1_21.zip",
      "changelog": ""
    }
  ]
}

Looks like that was updated properly, as v2.1 was the update being pulled (released 2h ago) – so for tests, just set "versions": 1 in track.json and remove v2.1 from update.json (but whom do I tell that 🙈).

Oh, the corresponding local/isodrive.json (looks like my local updater needs to be adjusted to not escape slashes – no idea why it suddenly does that):

{
    "version": "2.1",
    "versionCode": "21",
    "moduleProp": "https:\/\/github.com\/nitanmarcel\/isodrive-magisk\/raw\/master\/magisk-module\/module.prop",
    "urlPattern": "https:\/\/github.com\/nitanmarcel\/isodrive-magisk\/releases\/download\/v%v\/isodrive-magisk-v%v.zip",
    "zipUrl": "https:\/\/github.com\/nitanmarcel\/isodrive-magisk\/releases\/download\/v2.1\/isodrive-magisk-v2.1.zip",
    "changelog": ""
}
@IzzySoft
Copy link
Author

IzzySoft commented Sep 2, 2023

Wow, that was fast. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant