{"record":{"id":"96d3f68e1b4dd01a","repo":"nautechsystems/nautilus_trader","slug":"accountid-contains","errorCode":null,"errorMessage":"AccountId contains '-'","messagePattern":"AccountId contains '-'","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/model/src/identifiers/account_id.rs","lineNumber":115,"sourceCode":"    #[must_use]\n    pub fn inner(&self) -> Ustr {\n        self.0\n    }\n\n    /// Returns the inner identifier value as a string slice.\n    #[must_use]\n    pub fn as_str(&self) -> &str {\n        self.0.as_str()\n    }\n\n    /// Returns the account issuer for this identifier.\n    ///\n    /// # Panics\n    ///\n    /// Panics if the internal ID does not contain a hyphen separator.\n    #[must_use]\n    pub fn get_issuer(&self) -> Venue {\n        Venue::from_str_unchecked(self.0.split_once('-').expect(\"AccountId contains '-'\").0)\n    }\n\n    /// Returns the account ID assigned by the issuer.\n    ///\n    /// # Panics\n    ///\n    /// Panics if the internal ID does not contain a hyphen separator.\n    #[must_use]\n    pub fn get_issuers_id(&self) -> &str {\n        self.0.split_once('-').expect(\"AccountId contains '-'\").1\n    }\n}\n\nimpl Debug for AccountId {\n    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n        write!(f, \"\\\"{}\\\"\", self.0)\n    }\n}","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/identifiers/account_id.rs#L97-L133","documentation":"`AccountId::get_issuer` extracts the venue prefix of an account ID of the form `ISSUER-NUMBER` (e.g. `SIM-001`). It panics with \"AccountId contains '-'\" when the internal string contains no hyphen, meaning the ID was constructed bypassing validation (via `from_str_unchecked` or raw/new constructors) or the format contract changed. Well-formed AccountIds validated through the parser always contain a hyphen.","triggerScenarios":"Calling get_issuer() on an AccountId built with `AccountId::new`/unsafe unchecked constructors from a string lacking a hyphen, e.g. \"SIM001\" instead of \"SIM-001\".","commonSituations":"Deserializing account IDs from external config/CSV/databases with a different naming convention, hand-crafted IDs in tests, or upstream venue renames dropping the separator.","solutions":["Fix the account ID string so it includes the issuer hyphen separator, e.g. \"BINANCE-001\".","Construct AccountId via the checked `from_str`/parser path so malformed IDs are rejected at creation instead of panicking later.","Audit where the ID originates (config, database, adapter) and correct the formatting there.","If you must inspect arbitrary strings, split on '-' yourself and handle None instead of using get_issuer."],"exampleFix":"// before\nlet id = AccountId::new(\"SIM001\");\nlet issuer = id.get_issuer(); // panics\n// after\nlet id = AccountId::from_str(\"SIM-001\").expect(\"valid account id\");\nlet issuer = id.get_issuer(); // Venue(\"SIM\")","handlingStrategy":"validation","validationCode":"// Rust caller\nfn safe_issuer(id: &AccountId) -> Option<Venue> {\n    id.as_str().split_once('-').map(|(issuer, _)| Venue::from_str_unchecked(issuer))\n}","typeGuard":"fn is_well_formed_account_id(s: &str) -> bool {\n    s.split_once('-').map_or(false, |(issuer, num)| !issuer.is_empty() && !num.is_empty())\n}","tryCatchPattern":"// AccountId methods panic rather than return Result; validate first\nif is_well_formed_account_id(id.as_str()) {\n    let issuer = id.get_issuer();\n} else {\n    log::error!(\"malformed account id: {}\", id);\n}","preventionTips":["Always construct AccountId via the checked from_str/parser path.","Enforce the ISSUER-NUMBER convention when importing IDs from external systems.","Add a format assertion at ingestion boundaries (config load, DB read)."],"tags":["rust","panic","identifiers","format"],"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"}