{"record":{"id":"4447e05128171601","repo":"nautechsystems/nautilus_trader","slug":"invalid-interactive-brokers-account-id-e","errorCode":null,"errorMessage":"Invalid Interactive Brokers account_id: {e}","messagePattern":"Invalid Interactive Brokers account_id: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/factories.rs","lineNumber":204,"sourceCode":"        );\n\n        let client = InteractiveBrokersExecutionClient::new(core, ib_config, instrument_provider)?;\n        Ok(Box::new(client))\n    }\n\n    fn name(&self) -> &'static str {\n        IB\n    }\n\n    fn config_type(&self) -> &'static str {\n        stringify!(InteractiveBrokersExecutionClientConfig)\n    }\n}\n\nfn resolve_account_id(name: &str, account_id: &str) -> anyhow::Result<AccountId> {\n    if account_id.contains('-') {\n        return AccountId::new_checked(account_id)\n            .map_err(|e| anyhow::anyhow!(\"Invalid Interactive Brokers account_id: {e}\"));\n    }\n\n    let issuer = if name.is_empty() { IB } else { name };\n    AccountId::new_checked(format!(\"{issuer}-{account_id}\"))\n        .map_err(|e| anyhow::anyhow!(\"Invalid Interactive Brokers account_id: {e}\"))\n}\n\nfn seed_provider_from_cache(\n    instrument_provider: &InteractiveBrokersInstrumentProvider,\n    cache: &CacheView,\n) {\n    let instruments = {\n        let cache = cache.borrow();\n        cache\n            .instrument_ids(None)\n            .into_iter()\n            .filter_map(|instrument_id| cache.instrument(instrument_id).cloned())\n            .collect::<Vec<_>>()","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/factories.rs#L186-L222","documentation":"When the configured account_id already contains a dash, resolve_account_id validates it directly with AccountId::new_checked. If validation fails (bad characters or structure), the error is wrapped as 'Invalid Interactive Brokers account_id'. This branch treats the given ID as a fully-qualified issuer-account string.","triggerScenarios":"Setting account_id to a dash-containing string that is not a valid AccountId — e.g. 'IB--ABC', 'my-broker/account', trailing dash 'IB-', or containing spaces.","commonSituations":"Copy-pasting an account label from a broker statement that includes extra separators or whitespace; confusing the gateway's account name with a Nautilus AccountId.","solutions":["Inspect the wrapped error `e` to see why AccountId::new_checked rejected the string.","Use the exact format expected: '<ISSUER>-<ACCOUNT>' with valid identifier characters, e.g. 'IB-DU12345'.","Strip whitespace or extra separators before configuring account_id.","If you only have the bare account number, drop the dash-containing form and supply the raw ID so the issuer is prepended automatically."],"exampleFix":"// before\naccount_id = \"IB--DU12345\" // double dash, invalid\n// after\naccount_id = \"IB-DU12345\"","handlingStrategy":"validation","validationCode":"// only pass dash-containing ids that already validate\nlet _ = AccountId::new_checked(&account_id).expect(\"fully-qualified account_id must be valid\");","typeGuard":"fn is_valid_account_id(s: &str) -> bool {\n    AccountId::new_checked(s).is_ok()\n}","tryCatchPattern":"match resolve_account_id(name, account_id) {\n    Ok(id) => use(id),\n    Err(e) if e.to_string().contains(\"Invalid Interactive Brokers account_id\") => {\n        return Err(anyhow!(\"fix account_id format in config, expected 'ISSUER-ACCOUNT': {e}\"));\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Validate the account_id string against AccountId::new_checked before writing it into config","Copy account ids verbatim from the gateway without reformatting","Avoid spaces or extra separators around the dash"],"tags":["account-id","validation","config"],"backgroundTag":"invalid-identifier-format","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"}