{"record":{"id":"557c036fba2ad9ed","repo":"nautechsystems/nautilus_trader","slug":"invalid-field-raw-e","errorCode":null,"errorMessage":"invalid {field}='{raw}': {e}","messagePattern":"invalid (.+?)='(.+?)': (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/common/parse.rs","lineNumber":214,"sourceCode":"}\n\n/// Parses a venue price string into a `Price` at the given precision.\n///\n/// Returns `None` for unparsable, zero, or negative values. Goes through\n/// `Decimal` for exact comparison semantics.\n#[must_use]\npub(crate) fn parse_price_at_precision(raw: &str, precision: u8) -> Option<Price> {\n    let decimal = Decimal::from_str(raw).ok()?;\n    if !decimal.is_sign_positive() || decimal.is_zero() {\n        return None;\n    }\n\n    Price::from_decimal_dp(decimal, precision).ok()\n}\n\n/// Parses a required venue decimal string.\npub(crate) fn parse_required_decimal(raw: &str, field: &str) -> anyhow::Result<Decimal> {\n    Decimal::from_str(raw).map_err(|e| anyhow::anyhow!(\"invalid {field}='{raw}': {e}\"))\n}\n\n/// Parses a required venue quantity string into a `Quantity` at the given precision.\npub(crate) fn parse_required_quantity_at_precision(\n    raw: &str,\n    precision: u8,\n    field: &str,\n) -> anyhow::Result<Quantity> {\n    let decimal = parse_required_decimal(raw, field)?;\n    Quantity::from_decimal_dp(decimal, precision)\n        .map_err(|e| anyhow::anyhow!(\"invalid {field}='{raw}' at precision {precision}: {e}\"))\n}\n\n/// Parses a required venue price string into a `Price` at the given precision.\npub(crate) fn parse_required_price_at_precision(\n    raw: &str,\n    precision: u8,\n    field: &str,","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/common/parse.rs#L196-L232","documentation":"This is the base wrapper used for any required venue-supplied decimal string that fails `Decimal::from_str`. It means Binance sent a value in a field (price, quantity, commission, callback rate, fill report value) that is not a valid decimal number, and the adapter cannot proceed with that event.","triggerScenarios":"Any code path calling parse_required_decimal via parse_required_quantity_at_precision, parse_required_price_at_precision, to_fill_report, parse_positive_price_at_precision, parse_callback_rate_basis_points, or parse_order_commission, when the raw string is empty, contains characters like '-' or 'null', or has locale formatting (thousand separators).","commonSituations":"WebSocket order-update or fill events carrying unusual values; testnet endpoints returning placeholder data; a REST response field null/absent coerced to an empty string; copy-pasted fixtures from other exchanges.","solutions":["Inspect the raw message and the offending field value to see why it is not a plain decimal","Verify the event source (live vs testnet) returns real numeric strings","Strip or normalize unexpected characters before handing raw strings to the parser","Update the adapter if Binance changed the number formatting"],"exampleFix":"// before\nlet qty = parse_required_decimal(raw, \"origQty\")?;\n// after\nlet qty = match parse_required_decimal(raw, \"origQty\") {\n    Ok(q) => q,\n    Err(e) => { error!(\"dropping malformed order event: {e}\"); return Ok(()); }\n};","handlingStrategy":"try-catch","validationCode":"fn looks_like_decimal(s: &str) -> bool { !s.is_empty() && s.chars().all(|c| c.is_ascii_digit() || c == '.' || c == '-').then_some(()).is_some() }","typeGuard":"fn as_decimal_str(v: &serde_json::Value) -> Option<&str> { v.as_str().filter(|s| !s.is_empty() && s.parse::<Decimal>().is_ok()) }","tryCatchPattern":"match parse_required_decimal(raw, field) { Ok(d) => d, Err(e) => { error!(\"malformed field in venue message: {e}\"); return Ok(()); } }","preventionTips":["Log raw message payloads at debug level to aid diagnosis","Sanitize numeric strings before parsing","Avoid replaying data recorded from mismatched protocol versions"],"tags":["rust","parsing","decimal","binance"],"backgroundTag":"invalid-argument-format","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"}