{"record":{"id":"3ec92884d7e77387","repo":"nautechsystems/nautilus_trader","slug":"unknown-ib-security-type-value","errorCode":null,"errorMessage":"Unknown IB security type: {value}","messagePattern":"Unknown IB security type: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/common/enums/contracts.rs","lineNumber":136,"sourceCode":"    fn try_from(value: &ibapi::contracts::SecurityType) -> Result<Self, Self::Error> {\n        match value {\n            ibapi::contracts::SecurityType::Stock => Ok(Self::Stock),\n            ibapi::contracts::SecurityType::Option => Ok(Self::Option),\n            ibapi::contracts::SecurityType::Future => Ok(Self::Future),\n            ibapi::contracts::SecurityType::ContinuousFuture => Ok(Self::ContinuousFuture),\n            ibapi::contracts::SecurityType::Index => Ok(Self::Index),\n            ibapi::contracts::SecurityType::FuturesOption => Ok(Self::FuturesOption),\n            ibapi::contracts::SecurityType::ForexPair => Ok(Self::ForexPair),\n            ibapi::contracts::SecurityType::Spread => Ok(Self::Spread),\n            ibapi::contracts::SecurityType::Warrant => Ok(Self::Warrant),\n            ibapi::contracts::SecurityType::Bond => Ok(Self::Bond),\n            ibapi::contracts::SecurityType::Commodity => Ok(Self::Commodity),\n            ibapi::contracts::SecurityType::News => Ok(Self::News),\n            ibapi::contracts::SecurityType::MutualFund => Ok(Self::MutualFund),\n            ibapi::contracts::SecurityType::Crypto => Ok(Self::Crypto),\n            ibapi::contracts::SecurityType::CFD => Ok(Self::Cfd),\n            ibapi::contracts::SecurityType::Other(value) => {\n                anyhow::bail!(\"Unknown IB security type: {value}\")\n            }\n        }\n    }\n}\n\nimpl FromStr for IbSecurityType {\n    type Err = anyhow::Error;\n\n    fn from_str(value: &str) -> Result<Self, Self::Err> {\n        match value.to_ascii_uppercase().as_str() {\n            \"STK\" => Ok(Self::Stock),\n            \"OPT\" => Ok(Self::Option),\n            \"FUT\" => Ok(Self::Future),\n            \"CONTFUT\" => Ok(Self::ContinuousFuture),\n            \"IND\" => Ok(Self::Index),\n            \"FOP\" => Ok(Self::FuturesOption),\n            \"CASH\" => Ok(Self::ForexPair),\n            \"BAG\" => Ok(Self::Spread),","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/common/enums/contracts.rs#L118-L154","documentation":"IbSecurityType's TryFrom conversion maps ibapi contract SecurityType values onto the adapter's enum. When the ibapi crate yields SecurityType::Other(value) — a security type the adapter does not recognize — the conversion bails with the raw string embedded in the message. This prevents unsupported IB contract types from entering the adapter as a wrong default.","triggerScenarios":"Converting an IB contract's security type that is not one of the explicitly handled variants (Stock, Option, Futures, Forex, Index, Commodity, News, MutualFund, Crypto, CFD, etc.), e.g. when subscribing to or describing a contract whose secType the adapter hasn't mapped.","commonSituations":"Using exotic/less-common IB products (warrants, bonds, rights, spread contracts) whose secType maps to Other; a newer ibapi crate version introducing types the adapter doesn't cover; wiring up user-supplied secType strings not validated before conversion.","solutions":["Use a supported security type (Stock, Option, Future, Forex, Index, Cfd, Crypto, etc.) for the contract.","Add a mapping arm for the unsupported IB security type in the TryFrom impl if the adapter should support it.","Validate/whitelist the secType string before building the contract, failing with a clearer user-facing message.","Check ibapi crate version compatibility; a new enum variant may need adapter support."],"exampleFix":"// before\nlet sec_type = IbSecurityType::try_from(ib_contract.sec_type)?;\n// after\nlet sec_type = match IbSecurityType::try_from(ib_contract.sec_type) {\n    Ok(t) => t,\n    Err(e) => {\n        tracing::warn!(\"skipping contract with {e}\");\n        return Ok(None);\n    }\n};","handlingStrategy":"type-guard","validationCode":"fn is_supported_sec_type(s: &str) -> bool {\n    matches!(s, \"STK\" | \"OPT\" | \"FUT\" | \"CASH\" | \"IND\" | \"COM\" | \"NEWS\"\n        | \"FUND\" | \"CRYPTO\" | \"CFD\")\n}","typeGuard":"fn as_supported(t: &ibapi::contracts::SecurityType) -> Option<IbSecurityType> {\n    IbSecurityType::try_from(t.clone()).ok()\n}","tryCatchPattern":"let sec_type = match IbSecurityType::try_from(contract.sec_type) {\n    Ok(t) => t,\n    Err(e) => {\n        tracing::warn!(\"unsupported contract skipped: {e}\");\n        return Ok(None);\n    }\n};","preventionTips":["Whitelist allowed secType strings at configuration boundaries","Keep the adapter's TryFrom mapping in sync with the ibapi crate version","Log and skip unknown contract types instead of failing the whole data stream"],"tags":["interactive-brokers","rust","enum","contracts","conversion"],"backgroundTag":"unsupported-enum-value","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"}