-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Handle case of disconnected submissions #5345
fix: Handle case of disconnected submissions #5345
Conversation
@eloquence Found some issues. Not ready for review. 😓 |
@rmol @eloquence @redshiftzero So sqlalchemy does a cascade delete, on the other hand, directly running the query |
You could use that query in the test instead of deleting the source in the usual way: # db.session.delete(test_submissions['source'])
db.session.execute(
"DELETE FROM sources WHERE id = :id",
{"id": test_submissions["source"].id}
) |
@rmol Oh yes. Ofc. Thanks. |
@rmol Done. Ready for review. Tested the test on local. Didn't face the earlier issue. Works fine now. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. The test works. I've gone through the STR and verified that the Submission.to_json
changes solve the 500.
I had a bit of last-minute indecision about whether the get_all_submissions
API endpoint should even be returning disconnected submissions, instead of omitting those without a source, but the very name suggests it should. I checked the client code and it should properly deal with downloaded submissions which don't have a source -- if a new submission has no source, it is simply not added, and if the submission exists locally (which should only happen if the local source hasn't been deleted during a sync yet) it will be updated.
@rmol mmmm, ok. Ya sounds right not to return them. Let me know if we need to do that and I will edit the PR according to that. |
Yeah, when actually running the client I discovered that its handling of disconnected submissions is fine, but the SDK throws an exception when the source doesn't exist. And there are similar problems with the For this PR, adding a check of the source to return jsonify({'submissions': [s.to_json() for
s in submissions if s.source]}), 200 Thanks for persevering, @prateekj117! |
@rmol Sure. Will make those changes. |
04f4822
to
55c7d00
Compare
@rmol Done. Ready for another review. |
Thanks! I was hoping to just add the filtering of source-less submissions in |
@rmol Not an issue. Will do that change. |
@rmol Done. |
(CI failure likely unrelated, kicking) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks great, thanks for all your work on this @prateekj117.
Status
Ready for Review
Description of Changes
Fixes #5315 .
Changes proposed in this pull request:
Handled the case of disconnected submissions and added a test for the same.
Checklist
If you made changes to the server application code:
make lint
) and tests (make test
) pass in the development containerIf you made changes to
securedrop-admin
:make -C admin test
) pass in the admin development containerIf you made changes to the system configuration:
If you made non-trivial code changes:
If you made changes to documentation:
make docs-lint
) passed locally