diff --git a/bincio/extract/writer.py b/bincio/extract/writer.py index f4bd98d..512b263 100644 --- a/bincio/extract/writer.py +++ b/bincio/extract/writer.py @@ -382,7 +382,9 @@ def write_athlete_json(summaries: list[dict], output_dir: Path, athlete_config: **athlete_config, } (output_dir / "athlete.json").write_text( - json.dumps(athlete, indent=2, ensure_ascii=False) + json.dumps(athlete, indent=2, ensure_ascii=False), + encoding="utf-8", + errors="replace", ) diff --git a/bincio/serve/routers/activities.py b/bincio/serve/routers/activities.py index 143021b..2cc36fa 100644 --- a/bincio/serve/routers/activities.py +++ b/bincio/serve/routers/activities.py @@ -285,7 +285,10 @@ async def get_athlete(bincio_session: str | None = Cookie(default=None)) -> JSON athlete_path = dd / "athlete.json" data: dict = {} if athlete_path.exists(): - data = json.loads(athlete_path.read_text(encoding="utf-8")) + try: + data = json.loads(athlete_path.read_text(encoding="utf-8")) + except (json.JSONDecodeError, OSError): + pass # Layer edits/athlete.yaml on top edits_path = dd / "edits" / "athlete.yaml" if edits_path.exists():