You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consider raising errors for all messages with error bit set #56
The current Device class only raises errors if raise_on_error is set to true and the errors are "seen" during synchronous read/write operations. This leaves out anything that is either an Event, or unpaired Reads (e.g.: read dump). We should consider making this behavior uniform and instead raise before dispatching the messages to their own thread.
I should note, this is currently the behavior we have in the Bonsai client, where EVERY message can raise the error.
_request handles the error flag correctly, raising DeviceError only when raise_on_error is set and returning the reply otherwise. Then msg.decode(register) runs regardless. An error reply carries an empty payload, so decoding it against the register raises HarpParseError instead. Device.read does the same thing.
That contradicts the DeviceError docstring, which states that constructing the device with raise_on_error=False gives such a reply "as an ordinary return value instead".
This is already being hit as a limitation in downstream projects. The VertiGate hardware test opens the device with raise_on_error=False and carries a stand-in class so a parse failure on a reply can be read as a rejection.
Why it matters for the decision here. A conformance test asserting that a write must be refused needs exactly one documented way to observe the refusal, and "writing X must be rejected" is a common pattern in the specification. If this resolves toward every error-bit message raising, then raise_on_error either goes away or has to keep its contract, and the decode ordering above becomes moot. If both modes survive, decode should check has_error before decoding. Either is fine; what does not work is the current state, where the documented alternative raises a parse error.
Activity
glopesdev commentedon Sep 26, 2026
@bruno-f-cruz note the non-raising mode is currently broken, so today neither mode is a well-defined way to observe a rejected write.
Device.writeends with an unconditional decode:_requesthandles the error flag correctly, raisingDeviceErroronly whenraise_on_erroris set and returning the reply otherwise. Thenmsg.decode(register)runs regardless. An error reply carries an empty payload, so decoding it against the register raisesHarpParseErrorinstead.Device.readdoes the same thing.That contradicts the
DeviceErrordocstring, which states that constructing the device withraise_on_error=Falsegives such a reply "as an ordinary return value instead".This is already being hit as a limitation in downstream projects. The VertiGate hardware test opens the device with
raise_on_error=Falseand carries a stand-in class so a parse failure on a reply can be read as a rejection.Why it matters for the decision here. A conformance test asserting that a write must be refused needs exactly one documented way to observe the refusal, and "writing X must be rejected" is a common pattern in the specification. If this resolves toward every error-bit message raising, then
raise_on_erroreither goes away or has to keep its contract, and the decode ordering above becomes moot. If both modes survive,decodeshould checkhas_errorbefore decoding. Either is fine; what does not work is the current state, where the documented alternative raises a parse error.