-
Notifications
You must be signed in to change notification settings - Fork 15
Add integration test for R errors #547
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
Conversation
0196e97
to
1f5753d
Compare
5dd5e53
to
c74a84e
Compare
749f940
to
978026e
Compare
@@ -12,11 +12,11 @@ use crate::connection_file::ConnectionFile; | |||
use crate::session::Session; |
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.
I think I wish every reply was structured like this
pub enum ExecuteReply {
Success(ExecuteReplySuccess),
Exception(ExecuteReplyException),
}
There would be a lot of duplication, but I think it would make the structure a lot cleaner and less confusing. And ExecuteReplyException
's special case of adding the execution_count
would fit right in with no issues in this world - the ExecuteReplyException
would just have 1 more field than most exception structs
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.
It would be a bit like how we have ExecuteResponse
, but "response" is a confusing name because its really a "reply" that correctly encapsulates the two variants in the way id like them all to
pub enum ExecuteResponse {
Reply(ExecuteReply),
ReplyException(ExecuteReplyException),
}
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 was my feeling too.
Branched from #542
I was confused for a while trying to make tests for execution errors because of some puzzling ambiguities:
In the Jupyter protocol all replies have nominally one type (
foo_reply
withfoo
corresponding to the request name, e.g.foo_request
), but they each have two different structural types. When thestatus
field is "error", all fields are omitted and instead the exception fields (ename
,evalue
,stacktrace
, represented by the Rust typeException
) are included. The contents of the error variants of these messages are represented by the Rust typeErrorReply
, which currently has"error"
asmessage_type()
.As special case, the error variant of
"execute_reply"
messages must also preserve theexecution_count
field. This is represented by the Rust typeExecuteReplyException
.Ark handles this downstream and for this reason (I think) we don't use
send_error()
in Amalthea's Shell socket, we usesend_reply()
in both cases, which is also confusing:ark/crates/amalthea/src/socket/shell.rs
Line 235 in 1c7a78f
Execution errors are also signaled on IOPub with messages of type
"error"
. These are represented by the Rust typeExecuteError
.Things changed in this PR:
I was confused by
ErrorReply
having the samemessage_type()
(ark/crates/amalthea/src/wire/error_reply.rs
Line 31 in eef44b6
ExecuteError
messages (ark/crates/amalthea/src/wire/execute_error.rs
Line 24 in eef44b6
error_reply()
, seeark/crates/amalthea/src/wire/jupyter_message.rs
Line 347 in 1c7a78f
message_type()
method for type reasons involving expected traits. So I set the message type to"*error payload*"
to better reflect it's only a placeholder.We now take precautions in the
try_from()
method that deserialises Jupyter messages to disambiguate between the regular and error variants of"execute_reply"
.The error situation is now better documented so it's not as confusing the next time we have to deal with Jupyter errors.