{"record":{"id":"b6285b380ece97eb","repo":"nautechsystems/nautilus_trader","slug":"unknown-ib-action-value","errorCode":null,"errorMessage":"Unknown IB action: {value}","messagePattern":"Unknown IB action: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/common/enums/order.rs","lineNumber":96,"sourceCode":"            Self::Sell | Self::Sold => ibapi::orders::Action::Sell,\n            Self::SellShort => ibapi::orders::Action::SellShort,\n            Self::SellLong => ibapi::orders::Action::SellLong,\n        }\n    }\n}\n\nimpl FromStr for IbAction {\n    type Err = anyhow::Error;\n\n    fn from_str(value: &str) -> Result<Self, Self::Err> {\n        match value {\n            \"BUY\" => Ok(Self::Buy),\n            \"BOT\" => Ok(Self::Bought),\n            \"SELL\" => Ok(Self::Sell),\n            \"SLD\" => Ok(Self::Sold),\n            \"SSHORT\" => Ok(Self::SellShort),\n            \"SLONG\" => Ok(Self::SellLong),\n            _ => anyhow::bail!(\"Unknown IB action: {value}\"),\n        }\n    }\n}\n\nimpl From<ibapi::orders::Action> for IbAction {\n    fn from(value: ibapi::orders::Action) -> Self {\n        match value {\n            ibapi::orders::Action::Buy => Self::Buy,\n            ibapi::orders::Action::Sell => Self::Sell,\n            ibapi::orders::Action::SellShort => Self::SellShort,\n            ibapi::orders::Action::SellLong => Self::SellLong,\n        }\n    }\n}\n\nimpl Display for IbAction {\n    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n        f.write_str(match self {","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/common/enums/order.rs#L78-L114","documentation":"IbAction::from_str converts an IB order action string (BUY, SELL, and legacy BOT/SLD/SSHORT/SLONG) into the adapter's enum. Any other action string bails. It validates order-side data coming from IB order objects or user order submissions before mapping to Nautilus OrderSide.","triggerScenarios":"Parsing an ibapi order's `action` field containing a value outside {BUY, SELL, BOT, SLD, SSHORT, SLONG} — e.g. IB's \"P\" (parity) or \"C\" (cob) spread actions, empty strings, or user code calling IbAction::from_str with lowercase \"buy\" since this match is case-sensitive (no uppercase normalization shown in the arm list).","commonSituations":"Handling fill/order reports for combo or spread orders where IB uses single-letter parity actions instead of BUY/SELL; submitting orders through the adapter with a side string that isn't an exact uppercase IB action; strategy code mapping Nautilus OrderSide to strings with wrong casing.","solutions":["Use exact uppercase IB action strings: \"BUY\" or \"SELL\" for standard orders (the legacy BOT/SLD forms are also accepted).","If the value comes from an ibapi::orders::Action, convert with IbAction::from(value) instead of parsing its string.","If you must support parity/spread actions (\"P\"/\"C\"), extend the match in crates/adapters/interactive_brokers/src/common/enums/order.rs or reject such orders upstream."],"exampleFix":"// before\nlet action: IbAction = \"buy\".parse()?; // case-sensitive: fails\n// after\nlet action: IbAction = \"BUY\".parse()?; // or\nlet action: IbAction = raw_action.to_ascii_uppercase().parse()?;","handlingStrategy":"type-guard","validationCode":"fn is_valid_ib_action(v: &str) -> bool {\n    matches!(v, \"BUY\" | \"BOT\" | \"SELL\" | \"SLD\" | \"SSHORT\" | \"SLONG\")\n}","typeGuard":"fn as_ib_action(v: &str) -> Option<IbAction> {\n    use std::str::FromStr;\n    IbAction::from_str(v).ok()\n}","tryCatchPattern":"match action_str.parse::<IbAction>() {\n    Ok(a) => submit(a),\n    Err(e) => { log::error!(\"refusing order with bad action {action_str:?}: {e}\"); return OrderError::InvalidSide; }\n}","preventionTips":["Convert sides via the enum path (e.g. IbAction::from(ibapi_action)) rather than hand-built strings.","Use exact uppercase IB action strings; note this parser is case-sensitive, unlike some others in the adapter.","Avoid routing spread/parity actions (\"P\", \"C\") through this parser; handle combos separately."],"tags":["rust","enum-parsing","interactive-brokers","orders"],"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"}