{"record":{"id":"a84cf2fc760cb1eb","repo":"nautechsystems/nautilus_trader","slug":"invalid-price-match-value-s","errorCode":null,"errorMessage":"Invalid price_match value: {s:?}","messagePattern":"Invalid price_match value: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/common/enums.rs","lineNumber":507,"sourceCode":"    #[serde(other)]\n    Unknown,\n}\n\nimpl BinancePriceMatch {\n    /// Parses a price match mode from a string param value.\n    ///\n    /// Accepts uppercase Binance API values like `\"OPPONENT\"`, `\"OPPONENT_5\"`, `\"QUEUE_10\"`.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the value is not a recognized price match mode.\n    pub fn from_param(s: &str) -> anyhow::Result<Self> {\n        let value = s.to_uppercase();\n        serde_json::from_value(serde_json::Value::String(value))\n            .map_err(|_| anyhow::anyhow!(\"Invalid price_match value: {s:?}\"))\n            .and_then(|pm: Self| {\n                if pm == Self::None || pm == Self::Unknown {\n                    anyhow::bail!(\"Invalid price_match value: {s:?}\")\n                }\n                Ok(pm)\n            })\n    }\n}\n\n/// Self-trade prevention mode.\n#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]\n#[serde(rename_all = \"SCREAMING_SNAKE_CASE\")]\npub enum BinanceSelfTradePreventionMode {\n    /// No self-trade prevention.\n    None,\n    /// Expire maker orders on self-trade.\n    ExpireMaker,\n    /// Expire taker orders on self-trade.\n    ExpireTaker,\n    /// Expire both sides on self-trade.\n    ExpireBoth,","sourceCodeStart":489,"sourceCodeEnd":525,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/common/enums.rs#L489-L525","documentation":"PriceMatch is Binance's price-match/counterparty-best-match feature (e.g. OPPONENT, MAKER side values). from_param parses a case-insensitive string parameter via serde into the enum, then rejects both the explicit None and Unknown variants, since those are not valid requested price_match settings. Any string that neither deserializes to a variant nor passes that filter raises this error.","triggerScenarios":"Calling PriceMatch::from_param with a string that is not a recognized Binance price_match value (case-insensitive) — e.g. \"none\", \"unknown\", \"best-match\", or any typo like \"oponents\".","commonSituations":"Reading the price_match option from a config file or query parameter with an unexpected default (\"none\"); typos or wrong casing conventions in user config; copying values from another exchange's API that uses different naming.","solutions":["Pass a valid Binance price_match value: OPPONENT, or the maker-side variants accepted by the enum (e.g. MAKER_SIDE), with any casing.","Omit the price_match parameter entirely instead of passing \"None\".","Validate the config value against the enum's serializable variants at startup.","Check Binance's current API docs for the accepted price_match set if a valid-looking value still fails."],"exampleFix":"// before\nlet pm = PriceMatch::from_param(\"none\")?; // rejected: None variant not allowed\n// after\nlet pm = if price_match_param.is_empty() {\n    None // omit the feature\n} else {\n    Some(PriceMatch::from_param(&price_match_param)?) // e.g. \"OPPONENT\"\n};","handlingStrategy":"validation","validationCode":"const VALID_PRICE_MATCH: [&str; 3] = [\"OPPONENT\", \"MAKER_SIDE\", \"TAKER_SIDE\"];\nlet norm = param.to_uppercase();\nassert!(VALID_PRICE_MATCH.contains(&norm.as_str()), \"invalid price_match: {param}\");","typeGuard":"fn is_valid_price_match_param(s: &str) -> bool {\n    matches!(s.to_uppercase().as_str(), \"OPPONENT\" | \"MAKER_SIDE\" | \"TAKER_SIDE\")\n}","tryCatchPattern":"match PriceMatch::from_param(param) {\n    Ok(pm) => Some(pm),\n    Err(e) if e.to_string().contains(\"Invalid price_match value\") => {\n        log::warn!(\"ignoring invalid price_match {param:?}\");\n        None\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Omit the price_match option rather than sending \"None\".","Validate price_match against known variants when loading config, before building requests.","Check Binance docs for accepted values; do not reuse price-match names from other venues."],"tags":["binance","price-match","enum-parsing","config","rust"],"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-23T08:17:48.524Z"}