Skip to content

Refuse to overwrite a profiles.json that can't be read - #40

Merged
rangoDJ merged 1 commit into
mainfrom
fix/keep-damaged-profiles
Oct 7, 2026
Merged

rangoDJ merged 1 commit into
mainfrom
fix/keep-damaged-profiles

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Fixes #39

What changed

  • load_profiles(for_update=True) raises a 500 ("…/profiles.json is unreadable; fix or restore it before saving profiles") instead of returning [] when the file can't be parsed or isn't a list. save_profile() and remove_profile() use it, so they no longer write an empty list over a damaged file.
  • Listing (GET /api/profiles) and connecting keep the old behaviour: a damaged file shows as no profiles and is logged.

Testing

  • pytest: 229 passed, 3 skipped. New API tests: a truncated file lists as empty; save and delete return 500 and leave the file byte-for-byte unchanged; a non-list JSON file counts as damaged; a missing file is still created on first save. Three of them fail without the fix.
  • Not tested in a running container (no Docker on the dev machine); the change is backend-only and covered by the API tests.

🤖 Generated with Claude Code

An unreadable profiles.json listed as no profiles, and the next save or
delete wrote that empty list back over it, losing every saved profile.
Saving and deleting now fail with an error instead, so the file can be
fixed or restored first; listing still shows no profiles.

Fixes #39

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rangoDJ
rangoDJ merged commit 3ca7847 into main Oct 7, 2026
4 checks passed
@rangoDJ
rangoDJ deleted the fix/keep-damaged-profiles branch October 7, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A damaged profiles.json is overwritten (all profiles lost) on the next save

1 participant