{"record":{"id":"557c036fba2ad9ed","repo":"nautechsystems/nautilus_trader","slug":"invalid-field-raw-e","errorCode":null,"errorMessage":"invalid {field}='{raw}': {e}","messagePattern":"invalid (.+?)='(.+?)': (.+?)","errorType":"exception","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/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/common/parse.rs#L196-L232","documentation":"parse_required_decimal is the adapter's generic 'this venue string must be a decimal' helper (it feeds parse_required_quantity_at_precision and parse_required_price_at_precision). It calls Decimal::from_str on the raw string and bails with 'invalid {field}=...' when the string is not a valid decimal literal: rust_decimal rejects empty strings, 'null', stray text, and exponent notation.","triggerScenarios":"Any Binance response path that decodes a required size/price string into a typed value via parse_required_quantity_at_precision / parse_required_price_at_precision (balances, fees, quantities, prices) where the JSON value is null, empty, a boolean, or formatted with an exponent.","commonSituations":"Binance returns \"null\" or omits a field for accounts with no activity; a very small value starts rendering in scientific notation; test fixtures were recorded against a different API version; a proxy rewrites the payload.","solutions":["Use the field name and raw value in the error message to identify exactly which endpoint payload is malformed.","Update to the latest adapter version where venue response-format changes are handled.","If the field is legitimately optional on the venue, switch the calling code to the adapter's optional-decimal parsing helpers instead of the required variant.","Re-record or repair test fixtures whose JSON no longer matches the live API."],"exampleFix":"// before: endpoint serializes an empty balance as null\n// { \"qty\": null }\n\n// after: omit the field (optional path) or emit a valid decimal string\n// { \"qty\": \"0.00000000\" }","handlingStrategy":"validation","validationCode":"fn required_decimal_is_valid(raw: &str) -> bool {\n    rust_decimal::Decimal::from_str(raw).is_ok()\n}","typeGuard":null,"tryCatchPattern":"let value = match parse_required_decimal(raw, field) {\n    Ok(v) => v,\n    Err(e) => {\n        tracing::warn!(%field, %raw, \"invalid venue decimal: {e}\");\n        continue; // skip this record\n    }\n};","preventionTips":["Before replaying recorded responses, assert every required decimal field is a plain decimal string.","Prefer the adapter's optional-field parsing helpers for fields the venue legitimately omits or nulls.","Pin test fixtures to the API version they were recorded from."],"tags":["binance","decimal","venue-response","parse","rust"],"backgroundTag":"decimal-parse-error","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}