{"record":{"id":"441958df4dd7efff","repo":"nautechsystems/nautilus_trader","slug":"invalid-exec-algorithm-id-actor-id-type-441958","errorCode":null,"errorMessage":"Invalid `exec_algorithm_id`/`actor_id` type","messagePattern":"Invalid `exec_algorithm_id`/`actor_id` type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/trading/src/python/algorithm.rs","lineNumber":1273,"sourceCode":"    ///\n    /// # Errors\n    ///\n    /// Returns an error if an ID has an unsupported type or invalid value.\n    pub fn configure_from_py_config(&mut self, config: &Bound<'_, PyAny>) -> anyhow::Result<bool> {\n        let id = config\n            .getattr(\"exec_algorithm_id\")\n            .ok()\n            .filter(|id| !id.is_none())\n            .or_else(|| config.getattr(\"actor_id\").ok().filter(|id| !id.is_none()));\n        let has_id = if let Some(id) = id {\n            let exec_algorithm_id = if let Ok(exec_algorithm_id) = id.extract::<ExecAlgorithmId>() {\n                exec_algorithm_id\n            } else if let Ok(actor_id) = id.extract::<ActorId>() {\n                ExecAlgorithmId::new_checked(actor_id.inner())?\n            } else if let Ok(id) = id.extract::<String>() {\n                ExecAlgorithmId::new_checked(&id)?\n            } else {\n                anyhow::bail!(\"Invalid `exec_algorithm_id`/`actor_id` type\");\n            };\n            self.set_exec_algorithm_id(exec_algorithm_id);\n            true\n        } else {\n            false\n        };\n\n        if let Ok(log_events) = config.getattr(\"log_events\")\n            && let Ok(log_events) = log_events.extract::<bool>()\n        {\n            self.set_log_events(log_events);\n        }\n\n        if let Ok(log_commands) = config.getattr(\"log_commands\")\n            && let Ok(log_commands) = log_commands.extract::<bool>()\n        {\n            self.set_log_commands(log_commands);\n        }","sourceCodeStart":1255,"sourceCodeEnd":1291,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/trading/src/python/algorithm.rs#L1255-L1291","documentation":"In the Python bindings' exec_algorithm_id setter, the bound id object is tried as ExecAlgorithmId, ActorId, then plain string; if none extract successfully the setter bails. The Python object passed is not a recognized identifier type.","triggerScenarios":"Assigning a config/exec_algorithm_id attribute a value that is not an ExecAlgorithmId, ActorId, or str — e.g. a None, an int, or an arbitrary Python object.","commonSituations":"Passing None or an int where a string/identifier is expected in a Python config dict; building configs programmatically with unvalidated values; type confusion after refactoring the config schema.","solutions":["Pass an ExecAlgorithmId or ActorId instance, or the algorithm id as a str","Coerce the value: ExecAlgorithmId(value) before assignment (or str(value) if it is an ID string)","Validate the config value's type before constructing the config object"],"exampleFix":"# before\nconfig.exec_algorithm_id = 12345\n# after\nconfig.exec_algorithm_id = ExecAlgorithmId(\"EMA-CROSS\", \"EXEC-001\")  # or a valid string id","handlingStrategy":"type-guard","validationCode":"assert isinstance(cfg[\"exec_algorithm_id\"], (ExecAlgorithmId, ActorId, str)), f\"bad exec_algorithm_id type: {type(cfg['exec_algorithm_id'])}\"","typeGuard":"def is_valid_exec_algorithm_id(v) -> bool: return isinstance(v, (ExecAlgorithmId, ActorId, str))","tryCatchPattern":"try:\n    config.exec_algorithm_id = value\nexcept Exception:\n    config.exec_algorithm_id = ExecAlgorithmId(str(value))","preventionTips":["Validate config dicts before constructing config objects","Always pass identifier strings or typed IDs, never None/int/raw objects"],"tags":["python","bindings","type-error"],"backgroundTag":"type-mismatch","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"}