{"record":{"id":"590796b4a14d17f4","repo":"nautechsystems/nautilus_trader","slug":"missing-required-price-for-field-name","errorCode":null,"errorMessage":"Missing required price for `{field_name}`","messagePattern":"Missing required price for `(.+?)`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/decode/primitives.rs","lineNumber":233,"sourceCode":"        4 => \"Implied matching off\",\n        _ => anyhow::bail!(\"Invalid `StatusMsg` trading_event, was '{value}'\"),\n    };\n\n    Ok(Some(Ustr::from(value_str)))\n}\n\n/// Decodes a price, returning an error if undefined.\n///\n/// Databento uses `i64::MAX` as a sentinel value for unset/null prices (see\n/// [`UNDEF_PRICE`](https://docs.rs/dbn/latest/dbn/constant.UNDEF_PRICE.html)).\n///\n/// # Errors\n///\n/// Returns an error if `value` is `i64::MAX` (undefined).\n#[inline(always)]\npub fn decode_price(value: i64, precision: u8, field_name: &str) -> anyhow::Result<Price> {\n    if value == i64::MAX {\n        anyhow::bail!(\"Missing required price for `{field_name}`\")\n    } else {\n        Ok(Price::from_raw(decode_raw_price_i64(value), precision))\n    }\n}\n\n/// Decodes a price from the given optional value, expressed in units of 1e-9.\n///\n/// Databento uses `i64::MAX` as a sentinel value for unset/null prices (see\n/// [`UNDEF_PRICE`](https://docs.rs/dbn/latest/dbn/constant.UNDEF_PRICE.html)).\n#[inline(always)]\n#[must_use]\npub fn decode_optional_price(value: i64, precision: u8) -> Option<Price> {\n    if value == i64::MAX {\n        None\n    } else {\n        Some(Price::from_raw(decode_raw_price_i64(value), precision))\n    }\n}","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/decode/primitives.rs#L215-L251","documentation":"`decode_price` in the Databento adapter decodes an i64 price into a domain `Price`. Databento uses `i64::MAX` as the UNDEF sentinel for null/absent price fields, so when a required price field is undefined the function refuses to return a zero/garbage price and errors instead. It is thrown for required price fields (e.g. in instrument definition decoding) where a missing value cannot be tolerated.","triggerScenarios":"Calling `decode_price(value, precision, field_name)` with `value == i64::MAX`, e.g. an instrument definition record (option/futures contract) whose strike, activation, or other required price field was unset in the Databento response; also invoked directly in tests.","commonSituations":"Fetching definitions for instruments that legitimately lack a field (e.g. undefined strike for some derivatives), partial/malformed Databento records, or querying a schema where the price field is optional but the decode path treats it as required.","solutions":["Check the instrument/record on the Databento side for the missing field and exclude such symbols before requesting definitions.","If the field can legitimately be absent, switch the caller to `decode_optional_price` and handle `None` instead of erroring.","Inspect the raw dbn record for the offending `field_name` to confirm whether the upstream data is genuinely undefined.","Catch the anyhow error around `seed_price_precision_if_needed`/definition decoding and skip or log that instrument."],"exampleFix":"// before\nlet strike = decode_price(msg.strike_px as i64, precision, \"strike_px\")?;\n// after\nlet strike = if msg.strike_px == f64::NAN { None } else { Some(decode_price(msg.strike_px as i64, precision, \"strike_px\")?) };","handlingStrategy":"validation","validationCode":"fn price_defined(raw: i64) -> bool { raw != i64::MAX }","typeGuard":"fn is_undefined_price(v: i64) -> bool { v == i64::MAX }","tryCatchPattern":"match decode_price(raw, precision, \"strike_px\") {\n    Ok(p) => use(p),\n    Err(e) if e.to_string().contains(\"Missing required price\") => skip_instrument(),\n    Err(e) => return Err(e),\n}","preventionTips":["Check the sentinel (i64::MAX) before decoding any required price field.","Prefer decode_optional_price when the field may legitimately be absent.","Pre-filter instrument definitions with undefined fields for the symbols you request."],"tags":["databento","decode","price","sentinel-value"],"backgroundTag":"missing-required-argument","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"}