{"record":{"id":"18f17b5c022db330","repo":"nautechsystems/nautilus_trader","slug":"unknown-ib-option-right-value","errorCode":null,"errorMessage":"Unknown IB option right: {value}","messagePattern":"Unknown IB option right: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/common/enums/contracts.rs","lineNumber":223,"sourceCode":"\n    /// Converts this option right to a Nautilus option kind.\n    #[must_use]\n    pub const fn option_kind(self) -> OptionKind {\n        match self {\n            Self::Call => OptionKind::Call,\n            Self::Put => OptionKind::Put,\n        }\n    }\n}\n\nimpl FromStr for IbOptionRight {\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            \"C\" | \"CALL\" => Ok(Self::Call),\n            \"P\" | \"PUT\" => Ok(Self::Put),\n            _ => anyhow::bail!(\"Unknown IB option right: {value}\"),\n        }\n    }\n}\n\nimpl Display for IbOptionRight {\n    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n        f.write_str(self.as_str())\n    }\n}\n","sourceCodeStart":205,"sourceCodeEnd":233,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/common/enums/contracts.rs#L205-L233","documentation":"IbOptionRight::from_str parses an IB option right string into the adapter's Call/Put enum. Values other than \"C\"/\"CALL\"/\"P\"/\"PUT\" (case-insensitive, input is uppercased first) hit the bail. It guards against malformed or unmapped IB `right` fields on option contracts.","triggerScenarios":"Parsing an IB Contract's `right` field that is not a call/put designator — e.g. \"?\" (returned by IB for non-option contracts), empty string, or code passing a full name like \"Call\" with different text variants; direct IbOptionRight::from_str/parse calls with an unexpected value.","commonSituations":"Iterating IB positions or contract details where non-option instruments carry right=\"?\" or \"\" and the code parses the right unconditionally; options on futures or other structured products using unusual right codes; hand-written instrument configs with misspelled rights.","solutions":["Check the contract is actually an option (secType OPT/FOP) before parsing its `right` field; skip or handle non-option contracts separately.","Correct the value to \"C\"/\"CALL\" or \"P\"/\"PUT\" (any casing works, e.g. \"c\", \"Put\").","If IB returns a right code the adapter should support, add it to the match in crates/adapters/interactive_brokers/src/common/enums/contracts.rs."],"exampleFix":"// before\nlet right: IbOptionRight = contract.right.parse()?; // right == \"?\" for stocks\n// after\nlet right = if matches!(contract.sec_type.as_str(), \"OPT\" | \"FOP\") {\n    Some(contract.right.parse::<IbOptionRight>()?)\n} else {\n    None\n};","handlingStrategy":"type-guard","validationCode":"fn parseable_option_right(v: &str) -> bool {\n    matches!(v.to_ascii_uppercase().as_str(), \"C\" | \"CALL\" | \"P\" | \"PUT\")\n}","typeGuard":"fn as_ib_option_right(v: &str) -> Option<IbOptionRight> {\n    use std::str::FromStr;\n    IbOptionRight::from_str(v).ok()\n}","tryCatchPattern":"match contract.right.parse::<IbOptionRight>() {\n    Ok(right) => handle(right),\n    Err(e) => { log::debug!(\"non-option contract (right={:?}): {e}\", contract.right); }\n}","preventionTips":["Only parse `right` for contracts whose secType is OPT or FOP; IB reports \"?\" or empty for other instruments.","Treat a failed right parse as 'not an option' rather than a fatal error when scanning portfolios."],"tags":["rust","enum-parsing","interactive-brokers","options"],"backgroundTag":"invalid-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"}