Add passing test for unregistered err relay
Drop the `xfail` test and instead add a new one that ensures the `tractor._exceptions` fixes enable graceful relay of remote-but-unregistered error types via the unboxing of just the `rae.src_type_str/boxed_type_str` content. The test also ensures a warning is included with remote error content indicating the user should register their error type for effective cross-actor re-raising. Deats, - add `test_unregistered_err_still_relayed`: verify the `RemoteActorError` IS raised with `.boxed_type` as `None` but `.src_type_str`, `.boxed_type_str`, and `.tb_str` all preserved from the IPC msg. - drop `test_unregistered_boxed_type_resolution_xfail` since the new above case covers it and we don't need to have an effectively entirely repeated test just with an inverse assert as it's last line.. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codemulticast_revertable_streams
parent
a41c6d5c70
commit
80597b80bf
|
|
@ -257,29 +257,23 @@ def test_registered_another_err_relayed(
|
|||
assert rae.boxed_type is AnotherAppError
|
||||
|
||||
|
||||
@pytest.mark.xfail(
|
||||
reason=(
|
||||
'Unregistered custom error types are not '
|
||||
'resolvable by `get_err_type()` and thus '
|
||||
'`.boxed_type` will be `None`, indicating '
|
||||
'the framework cannot reconstruct the '
|
||||
'original remote error type - the user '
|
||||
'must call `reg_err_types()` to fix this.'
|
||||
),
|
||||
)
|
||||
def test_unregistered_custom_err_fails_lookup(
|
||||
def test_unregistered_err_still_relayed(
|
||||
debug_mode: bool,
|
||||
tpt_proto: str,
|
||||
):
|
||||
'''
|
||||
When a custom error type is NOT registered the
|
||||
received `RemoteActorError.boxed_type` should NOT
|
||||
match the original error type.
|
||||
Verify that even when a custom error type is NOT registered via
|
||||
`reg_err_types()`, the remote error is still relayed as
|
||||
a `RemoteActorError` with all string-level info preserved
|
||||
(traceback, type name, source actor uid).
|
||||
|
||||
This test is `xfail` to document the expected
|
||||
failure mode and to alert the user that
|
||||
`reg_err_types()` must be called for custom
|
||||
error types to relay correctly.
|
||||
The `.boxed_type` will be `None` (type obj can't be resolved) but
|
||||
`.boxed_type_str` and `.src_type_str` still report the original
|
||||
type name from the IPC msg.
|
||||
|
||||
This document the expected limitation: without `reg_err_types()`
|
||||
the `.boxed_type` property can NOT resolve to the original Python
|
||||
type.
|
||||
|
||||
'''
|
||||
# NOTE: intentionally do NOT call
|
||||
|
|
@ -307,7 +301,25 @@ def test_unregistered_custom_err_fails_lookup(
|
|||
|
||||
rae = excinfo.value
|
||||
|
||||
# XXX this SHOULD fail bc the type was never
|
||||
# registered and thus `get_err_type()` returns
|
||||
# `None` for the boxed type lookup.
|
||||
assert rae.boxed_type is UnregisteredAppError
|
||||
# the error IS relayed even without
|
||||
# registration; type obj is unresolvable but
|
||||
# all string-level info is preserved.
|
||||
assert rae.boxed_type is None # NOT `UnregisteredAppError`
|
||||
assert rae.src_type is None
|
||||
|
||||
# string names survive the IPC round-trip
|
||||
# via the `Error` msg fields.
|
||||
assert (
|
||||
rae.src_type_str
|
||||
==
|
||||
'UnregisteredAppError'
|
||||
)
|
||||
assert (
|
||||
rae.boxed_type_str
|
||||
==
|
||||
'UnregisteredAppError'
|
||||
)
|
||||
|
||||
# original traceback content is preserved
|
||||
assert 'this error type is unknown' in rae.tb_str
|
||||
assert 'UnregisteredAppError' in rae.tb_str
|
||||
|
|
|
|||
Loading…
Reference in New Issue