Skip to content

Fix silent data loss from bare except in store _load() methods#67

Merged
jasonmadigan merged 2 commits into
mainfrom
66-fix-store-load-silent-failure
Jun 4, 2026
Merged

Fix silent data loss from bare except in store _load() methods#67
jasonmadigan merged 2 commits into
mainfrom
66-fix-store-load-silent-failure

Conversation

@jasonmadigan

Copy link
Copy Markdown
Collaborator

Summary

Fixes a production incident where rootless container deployment (PR #50) against existing root-owned volumes caused all stores to silently cache empty dicts. API returned 200 with empty data, no errors in logs.

Closes #66

Changes

  • Store _load() error handling (all 5 stores): bare except Exception split into except OSError (re-raises -- data exists but unreadable) and except Exception (logs + empty dict -- corrupt/invalid data). Prevents cache poisoning on permission or filesystem errors.
  • Docker entrypoint: startup writability check on storage directory. Exits with actionable chown instructions if storage is not writable by the running user.
  • Tests: 24 new tests covering PermissionError re-raise, corrupt JSON graceful handling, and error logging for all active stores.

Test evidence

  • 96/96 backend tests pass
  • 24 new tests in test_store_load_errors.py covering all 4 active stores
  • DrawerStore excluded from tests (DrawerModel doesn't exist -- dead code)

PermissionError (data exists, can't read) now re-raises instead of
caching an empty dict. Corrupt JSON still falls back to empty with
logging. Docker entrypoint checks storage is writable at startup
with a clear remediation message for pre-rootless volumes.

Signed-off-by: Jason Madigan <[email protected]>
@jasonmadigan
jasonmadigan marked this pull request as ready for review June 4, 2026 22:00
@jasonmadigan
jasonmadigan merged commit 4bbbbe8 into main Jun 4, 2026
1 check passed
@jasonmadigan
jasonmadigan deleted the 66-fix-store-load-silent-failure branch June 4, 2026 22:01
shanetinklenberg pushed a commit to shanetinklenberg/tracefinity that referenced this pull request Jun 28, 2026
…finity#67)

* Fix silent data loss from bare except in store _load() methods (tracefinity#66)

PermissionError (data exists, can't read) now re-raises instead of
caching an empty dict. Corrupt JSON still falls back to empty with
logging. Docker entrypoint checks storage is writable at startup
with a clear remediation message for pre-rootless volumes.

Signed-off-by: Jason Madigan <[email protected]>

* Widen PermissionError to OSError, fix test gaps

Signed-off-by: Jason Madigan <[email protected]>

---------

Signed-off-by: Jason Madigan <[email protected]>
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.

Fix silent data loss from bare except in store _load() methods

1 participant