{"record":{"id":"e8c3913aa7bc89b7","repo":"nautechsystems/nautilus_trader","slug":"invalid-sl-order-type-was-other","errorCode":null,"errorMessage":"invalid `sl_order_type`, was {other}","messagePattern":"invalid `sl_order_type`, was (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/common/src/factories/order.rs","lineNumber":1741,"sourceCode":"                    true, // reduce_only\n                    quote_quantity,\n                    None, // display_qty\n                    emulation_trigger,\n                    trigger_instrument_id,\n                    sl_contingency_type,\n                    sl_order_list_id,\n                    sl_linked_order_ids,\n                    sl_parent_order_id,\n                    sl_exec_algorithm_id,\n                    sl_exec_algorithm_params,\n                    sl_exec_spawn_id,\n                    sl_tags,\n                    UUID4::new(),\n                    ts_init,\n                )?;\n                OrderAny::TrailingStopMarket(order)\n            }\n            other => anyhow::bail!(\"invalid `sl_order_type`, was {other}\"),\n        };\n\n        Ok(vec![entry_order, sl_order, tp_order])\n    }\n}\n\nfn required<T>(value: Option<T>, message: &'static str) -> anyhow::Result<T> {\n    value.ok_or_else(|| anyhow::anyhow!(message))\n}\n\n#[cfg(test)]\npub mod tests {\n    use std::{cell::RefCell, rc::Rc};\n\n    use indexmap::IndexMap;\n    use nautilus_core::UnixNanos;\n    use nautilus_model::{\n        enums::{","sourceCodeStart":1723,"sourceCodeEnd":1759,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/factories/order.rs#L1723-L1759","documentation":"This error is thrown by the bracket order factory when building a bracket (entry + stop-loss + take-profit) order and the supplied `sl_order_type` is not one of the supported stop-loss order types (stop-market or trailing-stop-market). The factory matches on the order type enum and falls through to this bail for any other variant. It means the caller passed an entry-style or unsupported order type where only specific stop-loss types are valid.","triggerScenarios":"Calling `OrderFactory::bracket(...)` (or `try_bracket`) with `sl_order_type` set to e.g. `OrderType::Limit`, `Market`, `StopLimit`, or any variant other than `StopMarket`/`TrailingStopMarket`. Typically caused by reusing the entry order type for the stop-loss parameter or misordering arguments.","commonSituations":"Config-driven strategies where the stop-loss order type is read from a config/CLI string and mapped incorrectly; code migrated from another API where bracket helpers accepted arbitrary stop types; typos passing the entry `OrderType` instead of the SL type.","solutions":["Pass `OrderType::StopMarket` or `OrderType::TrailingStopMarket` as `sl_order_type`","If a stop-limit is needed, construct the stop-loss order separately instead of via `bracket`","Check config parsing that produces `sl_order_type` and validate it against the supported set before calling `bracket`"],"exampleFix":"// before\nfactory.bracket(..., entry_order_type, sl_order_type = order_type, ...)\n// after\nlet sl_order_type = OrderType::StopMarket; // or TrailingStopMarket\nfactory.bracket(..., entry_order_type, sl_order_type, ...)","handlingStrategy":"validation","validationCode":"fn validate_sl_order_type(t: OrderType) -> Result<(), String> {\n    match t {\n        OrderType::StopMarket | OrderType::TrailingStopMarket => Ok(()),\n        other => Err(format!(\"sl_order_type must be StopMarket/TrailingStopMarket, was {other:?}\")),\n    }\n}","typeGuard":null,"tryCatchPattern":"let orders = match factory.bracket(...) {\n    Ok(o) => o,\n    Err(e) if e.to_string().contains(\"invalid `sl_order_type`\") => {\n        tracing::error!(\"bracket rejected sl_order_type: {e}\");\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n};","preventionTips":["Never reuse the entry order type as the stop-loss type","Validate order-type config strings against the supported SL set at startup","Write a unit test that builds a bracket with each configured SL type"],"tags":["rust","order-factory","invalid-argument"],"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"}