{"record":{"id":"ed79e3591ccffc70","repo":"nautechsystems/nautilus_trader","slug":"simulated-execution-factory-extractor-name-is","errorCode":null,"errorMessage":"Simulated execution factory extractor '{name}' is already registered","messagePattern":"Simulated execution factory extractor '(.+?)' is already registered","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/system/src/python/registry.rs","lineNumber":138,"sourceCode":"        }\n        extractors.insert(name, extractor);\n        Ok(())\n    }\n\n    /// Registers a simulated execution factory extractor for a specific factory name.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if a factory with the same name is already registered.\n    pub fn register_sim_exec_factory_extractor(\n        &self,\n        name: String,\n        extractor: SimulatedExecutionFactoryExtractor,\n    ) -> anyhow::Result<()> {\n        let mut extractors = self.sim_exec_factory_extractors.lock();\n\n        if extractors.contains_key(&name) {\n            anyhow::bail!(\"Simulated execution factory extractor '{name}' is already registered\");\n        }\n        extractors.insert(name, extractor);\n        Ok(())\n    }\n\n    /// Extracts a `Py<PyAny>` factory to a boxed `DataClientFactory` trait object.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if no extractor is registered for the factory type or extraction fails.\n    pub fn extract_factory(\n        &self,\n        py: Python<'_>,\n        factory: Py<PyAny>,\n    ) -> PyResult<Box<dyn DataClientFactory>> {\n        // Get the factory name to find the appropriate extractor\n        let factory_name = factory\n            .getattr(py, \"name\")?","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/python/registry.rs#L120-L156","documentation":"register_sim_exec_factory_extractor stores named simulated-execution factory extractors and rejects duplicate names. A second registration under an existing name would overwrite the original, so it is refused.","triggerScenarios":"Calling the public register_sim_exec_factory_extractor twice with the same `name` — module re-import, double setup of the sandbox/simulated venue stack, or name collision with another sim factory.","commonSituations":"Test suites that rebuild nodes per test without clearing the registry, notebooks re-running setup cells, custom sim fill-model adapters registered per-test.","solutions":["Register once per process or make the registration call idempotent.","Give custom sim factories unique names.","Reset/rebuild the registry between runs instead of re-registering into it."],"exampleFix":"// before\n# notebook cell re-run\nregister_sim_exec_factory_extractor(\"SimExec\", factory)\n// after\nif not registry.has_sim_exec_factory(\"SimExec\"):\n    register_sim_exec_factory_extractor(\"SimExec\", factory)","handlingStrategy":"try-catch","validationCode":"if name in registered_sim_exec_factories:\n    return\nregistered_sim_exec_factories.add(name)\nregister_sim_exec_factory_extractor(name, factory)","typeGuard":"def sim_factory_registered(name: str, names: set) -> bool:\n    return name in names","tryCatchPattern":"try:\n    register_sim_exec_factory_extractor(name, factory)\nexcept Exception as e:\n    if \"is already registered\" in str(e):\n        pass  # treat as idempotent\n    else:\n        raise","preventionTips":["Register sim factories once per process or guard with a set","Give custom sim fill/venue factories distinct names","Recreate the registry between test runs instead of re-registering"],"tags":["registration","duplicate","simulation","execution"],"backgroundTag":"file-already-exists","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}