Improve error-handling for deleted files, messages, and replies
Status
Ready for review
Description
Fixes #2217 by ensuring that database queries expecting exactly one File, Message, or Reply are error-handled. Note: This is a deliberately limited-scope fix; a broader discussion about database error-handling improvements will happen in https://github.com/freedomofpress/securedrop-client/issues/2222
Test Plan
- [ ] Visual Review
- [ ] CI
- [ ] Basic functionality testing (login, sync, download files and messages, delete conversation)
- Reproduce #2217 and ensure no app crash:
- Enable debug logs on the client. Submit a large file for a source (or a normal size file but use toxiproxy so that your download speed is limited).
- Begin downloading the file, then quicky, before the download can complete, delete the source.
- [ ] The app does not crash
- [ ] There is a warning in the logic.py logs about the deleted file ("get_file for uuid not found in database")
- [ ] The debug logs display the file uuid and stacktrace
Checklist
If these changes modify code paths involving cryptography, the opening of files in VMs or network (via the RPC service) traffic, Qubes testing in the staging environment is required. For fine tuning of the graphical user interface, testing in any environment in Qubes is required. Please check as applicable:
- [ ] I have tested these changes in the appropriate Qubes environment
- [ ] I do not have an appropriate Qubes OS workstation set up (the reviewer will need to test these changes)
- [ ] These changes should not need testing in Qubes
If these changes add or remove files other than client code, the AppArmor profile may need to be updated. Please check as applicable:
- [ ] I have updated the AppArmor profile
- [x] No update to the AppArmor profile is required for these changes
- [ ] I don't know and would appreciate guidance
If these changes modify the database schema, you should include a database migration. Please check as applicable:
- [ ] I have written a migration and upgraded a test database based on
mainand confirmed that the migration is self-contained and applies cleanly - [ ] I have written a migration but have not upgraded a test database based on
mainand would like the reviewer to do so - [ ] I need help writing a database migration
- [x] No database schema changes are needed
(Adding this to the 0.14.0 milestone even though it isn't strictly in the "multi-delete" category because it's a bugfix, does related to delete actions, and will be released with 0.14.0)
IMO instead of using exceptions, I think we'd benefit from making the functions like [...]
I agree and not sure why I didn't look at it that way before - addressed in https://github.com/freedomofpress/securedrop-client/pull/2231/commits/138643be480dd82bb9ed24b787a04307a8d8c1ae, thank you :)