{"record":{"id":"c3368a21dd1c6ea6","repo":"nautechsystems/nautilus_trader","slug":"failed-to-parse-field-name-value-value-int","errorCode":null,"errorMessage":"Failed to parse '{field_name}' value '{value}' into Decimal: {e}","messagePattern":"Failed to parse '(.+?)' value '(.+?)' into Decimal: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/dydx/src/common/parse.rs","lineNumber":120,"sourceCode":"    // Ensure we don't double-append when given a symbol already suffixed.\n    if !base.ends_with(\"-PERP\") {\n        base.push_str(\"-PERP\");\n    }\n    InstrumentId::new(Symbol::from_str_unchecked(&base), *DYDX_VENUE)\n}\n\n/// Parses a decimal string into a [`Price`].\n///\n/// Normalizes the decimal to strip trailing zeros and clamps precision to\n/// [`FIXED_PRECISION`] to prevent panics from venue values with excessive\n/// decimal places.\n///\n/// # Errors\n///\n/// Returns an error if the string cannot be parsed into a valid price.\npub fn parse_price(value: &str, field_name: &str) -> anyhow::Result<Price> {\n    let decimal = Decimal::from_str(value).map_err(|e| {\n        anyhow::anyhow!(\"Failed to parse '{field_name}' value '{value}' into Decimal: {e}\")\n    })?;\n    let normalized = decimal.normalize();\n    let precision = (normalized.scale() as u8).min(FIXED_PRECISION);\n    Price::from_decimal_dp(normalized, precision).map_err(|e| {\n        anyhow::anyhow!(\"Failed to parse '{field_name}' value '{value}' into Price: {e}\")\n    })\n}\n\n/// Parses a decimal string into a [`Quantity`].\n///\n/// Normalizes the decimal to strip trailing zeros and clamps precision to\n/// [`FIXED_PRECISION`] to prevent panics from venue values with excessive\n/// decimal places.\n///\n/// # Errors\n///\n/// Returns an error if the string cannot be parsed into a valid quantity.\npub fn parse_quantity(value: &str, field_name: &str) -> anyhow::Result<Quantity> {","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/dydx/src/common/parse.rs#L102-L138","documentation":"`parse_price` first converts the input string into a `rust_decimal::Decimal`; this error is thrown when `Decimal::from_str` fails, meaning the string is not a syntactically valid decimal number. The message names the field and the offending raw value plus the underlying parse error.","triggerScenarios":"Calling `parse_price(value, field_name)` with a non-numeric string, empty string, embedded whitespace, locale-formatted numbers (comma decimal separator), or scientific notation variants Decimal rejects.","commonSituations":"Prices sourced from config files, environment variables, CSV/manual entry, or upstream API strings that are malformed or empty before reaching the parser.","solutions":["Validate/trim the input string and confirm it is a plain decimal like \"100.5\" before calling parse_price","Normalize locale formatting (replace ',' with '.') before parsing","Log the offending `{value}` at the call site to find the data source producing bad values","For optional/empty inputs, handle emptiness before calling parse_price instead of passing \"\""],"exampleFix":"// before\nlet price = parse_price(&raw, \"entry_price\")?;\n// after\nlet raw = raw.trim();\nif raw.is_empty() { anyhow::bail!(\"entry_price is empty\"); }\nlet price = parse_price(raw, \"entry_price\")?;","handlingStrategy":"validation","validationCode":"fn valid_price_str(s: &str) -> bool {\n    let t = s.trim();\n    !t.is_empty() && t.chars().all(|c| c.is_ascii_digit() || c == '.')\n}","typeGuard":"fn parse_ok(s: &str) -> Option<rust_decimal::Decimal> { rust_decimal::Decimal::from_str(s.trim()).ok() }","tryCatchPattern":"let price = parse_price(raw, \"entry_price\")\n    .map_err(|e| { log::error!(\"bad price input: {e}\"); e })?;","preventionTips":["Normalize numeric strings (trim, strip units/commas) at config-load time","Use locale-free formats in all config and data files","Log raw values on parse failure to trace the bad source quickly"],"tags":["parsing","decimal","price","dydx"],"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-14T05:17:10.506Z"}