-
Notifications
You must be signed in to change notification settings - Fork 42
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
app crashes when object has no attribute 'reply_uuid' #820
Comments
I don't know how this could occur right now, but am putting here so someone else can comment if they've seen it |
I just came across a similar error, looks like the same underlying issue: STR
--- a/securedrop_client/api_jobs/uploads.py
+++ b/securedrop_client/api_jobs/uploads.py
@@ -96,7 +96,7 @@ class SendReplyJob(ApiJob):
# TODO: Once https://github.com/freedomofpress/securedrop-client/issues/648, we will want to
# pass the default request timeout to reply_source instead of setting it on the api object
# directly.
- api_client.default_request_timeout = 5
+ api_client.default_request_timeout = 0.01
return api_client.reply_source(sdk_source, encrypted_reply, self.reply_uuid)
ExpectedFor the reply to fail, the sync to succeed, the reply to retry and fail again (because the timeout is 0.01s) Actual
|
Interestingly, these changes fix the issue: Fix 1diff --git a/securedrop_client/api_jobs/uploads.py b/securedrop_client/api_jobs/uploads.py
index d5b451f..bbb5d5d 100644
--- a/securedrop_client/api_jobs/uploads.py
+++ b/securedrop_client/api_jobs/uploads.py
@@ -70,11 +70,11 @@ class SendReplyJob(ApiJob):
id=self.source_uuid, error=e)
# Update draft reply send status to FAILED
- reply_status = session.query(ReplySendStatus).filter_by(
- name=ReplySendStatusCodes.FAILED.value).one()
- draft_reply_db_object.send_status_id = reply_status.id
- session.add(draft_reply_db_object)
- session.commit()
+ # reply_status = session.query(ReplySendStatus).filter_by(
+ # name=ReplySendStatusCodes.FAILED.value).one()
+ # draft_reply_db_object.send_status_id = reply_status.id
+ # session.add(draft_reply_db_object)
+ # session.commit()
raise SendReplyJobTimeoutError(message, self.reply_uuid)
except Exception as e:
@@ -96,7 +96,7 @@ class SendReplyJob(ApiJob):
# TODO: Once https://github.com/freedomofpress/securedrop-client/issues/648, we will want to
# pass the default request timeout to reply_source instead of setting it on the api object
# directly.
- api_client.default_request_timeout = 5
+ api_client.default_request_timeout = 0.01
return api_client.reply_source(sdk_source, encrypted_reply, self.reply_uuid)
If you uncomment those lines ^ then you'll see the issue again. Fix 2--- a/securedrop_client/api_jobs/uploads.py
+++ b/securedrop_client/api_jobs/uploads.py
@@ -76,7 +76,7 @@ class SendReplyJob(ApiJob):
session.add(draft_reply_db_object)
session.commit()
- raise SendReplyJobTimeoutError(message, self.reply_uuid)
+ raise SendReplyJobError(message, self.reply_uuid)
except Exception as e:
message = "Failed to send reply for source {id} due to Exception: {error}".format(
id=self.source_uuid, error=e)
@@ -96,7 +96,7 @@ class SendReplyJob(ApiJob):
# TODO: Once https://github.com/freedomofpress/securedrop-client/issues/648, we will want to
# pass the default request timeout to reply_source instead of setting it on the api object
# directly.
- api_client.default_request_timeout = 5
+ api_client.default_request_timeout = 0.01
return api_client.reply_source(sdk_source, encrypted_reply, self.reply_uuid) for some reason we don't see the same error when raising Fix 3--- a/securedrop_client/api_jobs/uploads.py
+++ b/securedrop_client/api_jobs/uploads.py
@@ -96,7 +96,7 @@ class SendReplyJob(ApiJob):
# TODO: Once https://github.com/freedomofpress/securedrop-client/issues/648, we will want to
# pass the default request timeout to reply_source instead of setting it on the api object
# directly.
- api_client.default_request_timeout = 5
+ api_client.default_request_timeout = 0.01
return api_client.reply_source(sdk_source, encrypted_reply, self.reply_uuid)
@@ -106,7 +106,7 @@ class SendReplyJobError(Exception):
self.reply_uuid = reply_uuid
-class SendReplyJobTimeoutError(RequestTimeoutError):
+class SendReplyJobTimeoutError(Exception):
def __init__(self, message: str, reply_uuid: str) -> None:
super().__init__()
self.reply_uuid = reply_uuid |
at least two issues to resolve:
1 is happening because if an exception is raised in this code, an exception will not be handled. We should ensure that we handle exceptions here too (wip diff in https://github.com/freedomofpress/securedrop-client/compare/exc-reply-crasher resolving). That diff will also handle the cases @creviera found above where the timeout being set very short, since the root issue there is also the lack of exception handling when setting the reply status to failed. 2 ... still investigating. It makes sense that an
This is uncovered due to #825, causing replies to continually be resent even when successful |
I think we can avoid this by making sure to only ever raise except (RequestTimeoutError, ServerConnectionError) as e:
message = "Failed to send reply for source {id} due to Exception: {error}".format(
id=self.source_uuid, error=e)
# Update draft reply send status to FAILED
reply_status = session.query(ReplySendStatus).filter_by(
name=ReplySendStatusCodes.FAILED.value).one()
draft_reply_db_object.send_status_id = reply_status.id
session.add(draft_reply_db_object)
session.commit()
raise SendReplyJobTimeoutError(message, self.reply_uuid)
except Exception as e:
message = "Failed to send reply for source {id} due to Exception: {error}".format(
id=self.source_uuid, error=e)
# Update draft reply send status to FAILED
reply_status = session.query(ReplySendStatus).filter_by(
name=ReplySendStatusCodes.FAILED.value).one()
draft_reply_db_object.send_status_id = reply_status.id
session.add(draft_reply_db_object)
session.commit()
raise SendReplyJobError(message, self.reply_uuid) As you pointed out, our code that updates the draft reply send status to FAILED in the catch block can raise other errors, e.g. Catching the errors that can occur when updating the draft reply send status to FAILED is only part of the solution though, because this error also happens
It looks like it's also happening when no exception is raised in that code, because another exception, e.g. So for followup I'll look into why that |
Results from further digging:
We shouldn't be doing this. It doesn't make sense for us to insert a new Reply into the local database because the reply is already stored as a DraftReply and needs to be resent, but this is what we're doing along with deleting the DraftReply that the job in the queue still expects to exist. -- My next step is to investigate the |
STR
Use diff in Replies are sometimes displayed out of order #653not necessaryExpected behavior
I repro that bug
Actual behavior
The text was updated successfully, but these errors were encountered: