From 35291575597044870a70133f9eccda271a7b05d3 Mon Sep 17 00:00:00 2001 From: goodboy Date: Wed, 2 Dec 2026 17:24:15 -0500 Subject: [PATCH] Register `MarketNotFound` for Binance RPC errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A lookup for `btcusdt.binance` already reports the missing venue in the child actor. The caller gets the same hint, but Tractor leaves `RemoteActorError.boxed_type` unset. Its registry only knows the direct `BrokerError` subclasses that piker hands it at import. Deats, - Register `MarketNotFound` alongside those direct subclasses. It inherits from `SymbolNotFound` one level further down. - Call Binance’s `get_mkt_info()` over a local Tractor portal and check both the exception class and the expected FQME in the parent. The missing venue exercises the failure before exchange lookup, so the regression runs offline. (this patch was generated in some part by `Codex` using `GPT-6` (`OpenAI`)) --- piker/brokers/_util.py | 1 + tests/providers/test_binance_market_lookup.py | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/providers/test_binance_market_lookup.py diff --git a/piker/brokers/_util.py b/piker/brokers/_util.py index 3049f4dc..b45ef426 100644 --- a/piker/brokers/_util.py +++ b/piker/brokers/_util.py @@ -119,6 +119,7 @@ class SchemaMismatch(BrokerError): reg_err_types([ BrokerError, *BrokerError.__subclasses__(), + MarketNotFound, # indirect subclass via SymbolNotFound ]) diff --git a/tests/providers/test_binance_market_lookup.py b/tests/providers/test_binance_market_lookup.py new file mode 100644 index 00000000..e8d8cd27 --- /dev/null +++ b/tests/providers/test_binance_market_lookup.py @@ -0,0 +1,53 @@ +''' +Binance market lookup errors across Tractor RPC. + +''' +import pytest +import tractor +import trio + +from piker.brokers import MarketNotFound +from piker.brokers.binance import feed as binance_feed + + +def test_missing_venue_error_over_rpc( + reg_addr: tuple[str, int|str], +) -> None: + ''' + Preserve Binance's missing-venue error across an actor boundary. + + - A market with no venue fails before exchange lookup. The + parent receives the diagnostic even if Tractor cannot resolve + the concrete exception in its local error registry. + - Call ``get_mkt_info()`` in a child and check both the expected + market format and ``RemoteActorError.boxed_type``. Direct + calls cannot expose a missing IPC exception registration. + + ''' + async def main() -> None: + ''' + Send the invalid market through the child's RPC endpoint. + + ''' + async with ( + tractor.open_root_actor(registry_addrs=[reg_addr]), + tractor.open_nursery() as an, + ): + portal: tractor.Portal = await an.start_actor( + 'binance_lookup', + enable_modules=[binance_feed.__name__], + ) + with pytest.raises(tractor.RemoteActorError) as raised: + await portal.run_from_ns( + binance_feed.__name__, + 'get_mkt_info', + fqme='btcusdt.binance', + ) + + await portal.cancel_actor() + + exc: tractor.RemoteActorError = raised.value + assert exc.boxed_type is MarketNotFound + assert 'expected-form>> btcusdt..binance' in str(exc) + + trio.run(main)