fix: handle empty/invalid athlete.json in merge, API read, and writer encoding

This commit is contained in:
Davide Scaini
2026-05-25 20:00:18 +02:00
parent 447d56a960
commit 0d6bf57932
2 changed files with 7 additions and 2 deletions
+4 -1
View File
@@ -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():