{"record":{"id":"a4b0985e28064786","repo":"nautechsystems/nautilus_trader","slug":"failed-to-register-pydataactor-e","errorCode":null,"errorMessage":"Failed to register PyDataActor: {e}","messagePattern":"Failed to register PyDataActor: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/system/src/python/registration.rs","lineNumber":434,"sourceCode":"    fn register_python_data_actor(\n        &mut self,\n        actor: &Py<PyAny>,\n        component_id: ComponentId,\n    ) -> anyhow::Result<()> {\n        let clock = self.create_component_clock(component_id);\n        let trader_id = self.trader_id;\n        let cache = self.cache.clone();\n\n        Python::attach(|py| -> anyhow::Result<()> {\n            let py_actor = actor.bind(py);\n            let mut py_data_actor_ref = py_actor\n                .extract::<PyRefMut<PyDataActor>>()\n                .map_err(Into::<PyErr>::into)\n                .map_err(|e| anyhow::anyhow!(\"Failed to extract PyDataActor: {e}\"))?;\n\n            py_data_actor_ref\n                .register(trader_id, clock, cache)\n                .map_err(|e| anyhow::anyhow!(\"Failed to register PyDataActor: {e}\"))?;\n\n            log::debug!(\n                \"Internal PyDataActor registered: {}, state: {:?}\",\n                py_data_actor_ref.is_registered(),\n                py_data_actor_ref.state()\n            );\n\n            Ok(())\n        })?;\n\n        Python::attach(|py| -> anyhow::Result<()> {\n            let py_actor = actor.bind(py);\n            let py_data_actor_ref = py_actor\n                .cast::<PyDataActor>()\n                .map_err(|e| anyhow::anyhow!(\"Failed to downcast to PyDataActor: {e}\"))?;\n            py_data_actor_ref.borrow().register_in_global_registries()?;\n            Ok(())\n        })","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/python/registration.rs#L416-L452","documentation":"NautilusTrader throws this when a Python actor object implementing the PyDataActor trait fails during its `register(trader_id, clock, cache)` call while being attached to a trader. The actor's own registration logic (e.g. subscribing, state transitions) raised a Python error, which is wrapped in an anyhow error. It means the actor could not be fully initialized inside the trading system.","triggerScenarios":"Calling `trader.add_data_actor(actor)` (or adding an actor via a node config) where the actor's `register()` — or any code it calls such as `subscribe_*` in on_start registration paths — raises a Python exception. Any Python-side error inside the actor during registration surfaces as this message.","commonSituations":"Actor constructors or registration hooks referencing unavailable config, importing modules that are missing, misconfigured subscription parameters (invalid instrument IDs, client IDs), or bugs in custom actor code that run during registration.","solutions":["Read the chained `{e}` message to find the underlying Python exception and fix the actor code that raised it","Verify all actor config values are valid before adding the actor to the trader","Confirm any clients/adapters the actor's subscriptions depend on are registered before the actor","Run the actor registration in isolation with logging enabled to pinpoint the failing hook"],"exampleFix":"// before: actor with bad config raises inside register\ntrader.add_actor(MyActor(config=MyActorConfig(instrument_id=\"INVALID\")))\n// after: validate first\ninstrument_id = InstrumentId.from_str(\"BTCUSDT.BINANCE\")  # raises early if bad\ntrader.add_actor(MyActor(config=MyActorConfig(instrument_id=instrument_id)))","handlingStrategy":"try-catch","validationCode":"# before adding actor\nassert isinstance(actor, Actor), \"actor must subclass nautilus_trader Actor\"\nactor.validate_config()  # or validate config fields manually","typeGuard":"def is_valid_actor(obj) -> bool:\n    from nautilus_trader.common.actor import Actor\n    return isinstance(obj, Actor)","tryCatchPattern":"try:\n    trader.add_data_actor(actor)\nexcept Exception as e:\n    logging.exception(\"actor registration failed: %s\", e)\n    raise","preventionTips":["Validate actor config fields before registering","Register required clients/adapters before actors that depend on them","Test actors standalone in a backtest node before live use"],"tags":["python","actor-registration","system"],"backgroundTag":"actor-registration-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}