{"record":{"id":"d4bae77fbac36d5f","repo":"nautechsystems/nautilus_trader","slug":"execution-client-factory-name-is-already-regis","errorCode":null,"errorMessage":"Execution client factory '{name}' is already registered","messagePattern":"Execution client factory '(.+?)' is already registered","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/common/src/factories/client.rs","lineNumber":213,"sourceCode":"    #[must_use]\n    pub fn new() -> Self {\n        Self {\n            factories: AHashMap::new(),\n        }\n    }\n\n    /// Registers an execution client factory.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if a factory with the same name is already registered.\n    pub fn register(\n        &mut self,\n        name: String,\n        factory: Box<dyn ExecutionClientFactory>,\n    ) -> anyhow::Result<()> {\n        if self.factories.contains_key(&name) {\n            anyhow::bail!(\"Execution client factory '{name}' is already registered\");\n        }\n\n        self.factories.insert(name, factory);\n        Ok(())\n    }\n\n    /// Gets a registered factory by name (if found).\n    #[must_use]\n    pub fn get(&self, name: &str) -> Option<&dyn ExecutionClientFactory> {\n        self.factories.get(name).map(std::convert::AsRef::as_ref)\n    }\n\n    /// Gets a list of all registered factory names.\n    #[must_use]\n    pub fn names(&self) -> Vec<&String> {\n        self.factories.keys().collect()\n    }\n","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/factories/client.rs#L195-L231","documentation":"ExecutionClientFactoryRegistry::register likewise rejects duplicate names: registering an ExecutionClientFactory under a name already present in `factories` bails with this error. Each execution client factory must have a distinct name key so client resolution is deterministic.","triggerScenarios":"Calling `register(name, factory)` twice with the same `name` on the same ExecutionClientFactoryRegistry, e.g. both a built-in setup and user code registering an execution factory with the identical client name.","commonSituations":"A venue package that ships both data and execution factories where the execution one is registered twice (once by library init, once by the user); colliding plugin names; re-running registration logic on the same registry.","solutions":["Check for the name before registering and skip or return early if already present.","Rename one of the conflicting factories to a unique, namespaced name.","Ensure execution factory registration occurs in a single place during node setup.","If a global/static registry is shared, reset or recreate it between runs/tests."],"exampleFix":"// before\nexec_registry.register(\"Binance\".to_string(), exec_factory)?;\n\n// after\nif !exec_registry.contains(\"Binance\") {\n    exec_registry.register(\"Binance\".to_string(), exec_factory)?;\n}","handlingStrategy":"validation","validationCode":"// Rust\nfn ensure_absent(registry: &ExecutionClientFactoryRegistry, name: &str) -> anyhow::Result<()> {\n    if registry.contains(name) {\n        anyhow::bail!(\"execution factory '{}' already registered; skipping\", name);\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match exec_registry.register(name.clone(), factory) {\n    Ok(()) => {}\n    Err(e) if e.to_string().contains(\"already registered\") => {\n        log::debug!(\"execution factory {name} already present; reusing existing\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Perform execution factory registration exactly once during node setup.","Use unique, namespaced factory names for third-party clients.","In tests, build a fresh registry per test instead of reusing a global one."],"tags":["rust","registry","duplicate-key","factory"],"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"}