fix(sdk): TcpTransport.send_push raises on OP_ERROR_RESPONSE instead of returning the error envelope#130
Merged
Conversation
…of returning error envelope
send_push blindly JSON-decoded the response frame and returned the dict
regardless of opcode. On OP_ERROR_RESPONSE (invalid_event, unknown_field_v0,
etc.) the error envelope {"error":{"code":...}} came back as a normal
return value — fire-and-forget callers silently dropped events on validation
failure. Embed mode defaults to TCP, so this hit the canonical docs path.
Mirror send_get: if frame.op != OP_PUSH, parse the body and raise
RegistrationError with the server code (or 'unparseable_error' /
'unexpected_frame' as fallback).
Flip the 5 type-mismatch tests in test_type_error_at_push.py from asserting
the buggy {"error": ...} return shape to pytest.raises(RegistrationError);
add 2 new tests covering unexpected opcode and unparseable error body via an
in-process TCP mock.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
`TcpTransport.send_push` was blindly JSON-decoding the response frame and returning the dict to user code. When the server emitted `OP_ERROR_RESPONSE` (e.g. `invalid_event` on a type mismatch), the error envelope was returned as a regular dict — no exception. Embed mode defaults to TCP, so fire-and-forget pushes silently `/dev/null` on validation failure.
PR #120 documented this and locked the buggy behaviour with `test_type_error_at_push.py`. This PR fixes the bug and flips those tests to assert the correct contract.
Fix in `python/beava/_transport.py`
`send_push` (lines 443-490) now mirrors `send_get`:
Docstring expanded with success/error wire shapes and `Raises:` section.
Test flips in `python/tests/test_type_error_at_push.py`
"`.Test plan