{"record":{"id":"72d6486c509ef774","repo":"nautechsystems/nautilus_trader","slug":"unsupported-order-side-only-buy-and-sell-are-s","errorCode":null,"errorMessage":"Unsupported order side {}; only Buy and Sell are supported","messagePattern":"Unsupported order side (.+?); only Buy and Sell are supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":1559,"sourceCode":"    /// Validates a submit-order command against the configured policy and builds the swap plan.\n    ///\n    /// Local checks run first: pool resolution, order semantics, allowlists, amount and\n    /// slippage limits, and the quote derived from the live pool profiler. Infrastructure\n    /// readiness (connection, in-flight slot, durable store, signer) follows. Chain state is\n    /// verified in the spawned task before signing.\n    fn prepare_swap(&self, cmd: &SubmitOrder, order: &OrderAny) -> anyhow::Result<SwapPlan> {\n        let instrument_id = order.instrument_id();\n        let pool = self.resolve_pool(&instrument_id)?;\n\n        if order.order_type() != OrderType::Market {\n            anyhow::bail!(\n                \"Unsupported order type {}; only Market is supported\",\n                order.order_type()\n            );\n        }\n\n        if !matches!(order.order_side(), OrderSide::Buy | OrderSide::Sell) {\n            anyhow::bail!(\n                \"Unsupported order side {}; only Buy and Sell are supported\",\n                order.order_side()\n            );\n        }\n\n        if order.is_quote_quantity() {\n            anyhow::bail!(\n                \"Quote-denominated quantities are not supported; quantity must be denominated in the base token\"\n            );\n        }\n\n        let fee = pool\n            .fee\n            .ok_or_else(|| anyhow::anyhow!(\"Pool {instrument_id} has no fee tier\"))?;\n        let fee = U24::try_from(fee)\n            .map_err(|_| anyhow::anyhow!(\"Pool {instrument_id} fee {fee} exceeds uint24\"))?;\n\n        let base_token = pool.get_base_token();","sourceCodeStart":1541,"sourceCodeEnd":1577,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L1541-L1577","documentation":"prepare_swap only supports OrderSide::Buy and OrderSide::Sell; any other side value is rejected. A swap always moves value in one direction, so both a side must be present and it must be one of the two directional values.","triggerScenarios":"submit_order called with an order whose order_side() is neither Buy nor Sell (e.g. an uninitialized/default side, or a side variant from another venue vocabulary).","commonSituations":"Constructing orders programmatically and forgetting to set the side; deserializing orders from an external system where the side field maps to a different variant; copying order-construction code from a venue with different side semantics.","solutions":["Set order_side explicitly to OrderSide::Buy or OrderSide::Sell before submitting.","Validate/normalize the side when ingesting orders from external systems before they reach submit_order."],"exampleFix":"// before\nlet order = OrderAny::default(); // side unset\nclient.submit_order(cmd, &order)?;\n// after\nlet mut order = OrderAny::default();\norder.set_order_side(OrderSide::Buy);\nclient.submit_order(cmd, &order)?;","handlingStrategy":"validation","validationCode":"// Rust\nif !matches!(order.order_side(), OrderSide::Buy | OrderSide::Sell) {\n    return Err(anyhow::anyhow!(\"order side must be Buy or Sell\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set order side explicitly when constructing orders programmatically.","Validate sides when deserializing external order payloads.","Use exhaustive matches on OrderSide in strategy code."],"tags":["blockchain","order-side","invalid-argument","swap"],"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-14T00:17:10.932Z"}