{"record":{"id":"d542809e125ac397","repo":"nautechsystems/nautilus_trader","slug":"failed-to-parse-continuous-future-adjustment-mod","errorCode":null,"errorMessage":"failed to parse `{CONTINUOUS_FUTURE_ADJUSTMENT_MODE}`","messagePattern":"failed to parse `(.+?)`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/data/src/engine/requests.rs","lineNumber":490,"sourceCode":"    Ok(bar_types)\n}\n\nfn parse_adjustment_mode(value: Option<&Value>) -> anyhow::Result<ContinuousFutureAdjustmentType> {\n    let Some(value) = value else {\n        return Ok(ContinuousFutureAdjustmentType::default());\n    };\n\n    if let Some(raw) = value.as_str() {\n        return ContinuousFutureAdjustmentType::from_str(raw)\n            .with_context(|| format!(\"failed to parse `{CONTINUOUS_FUTURE_ADJUSTMENT_MODE}`\"));\n    }\n\n    match value.as_u64() {\n        Some(1) => Ok(ContinuousFutureAdjustmentType::BackwardSpread),\n        Some(2) => Ok(ContinuousFutureAdjustmentType::ForwardSpread),\n        Some(3) => Ok(ContinuousFutureAdjustmentType::BackwardRatio),\n        Some(4) => Ok(ContinuousFutureAdjustmentType::ForwardRatio),\n        _ => anyhow::bail!(\"failed to parse `{CONTINUOUS_FUTURE_ADJUSTMENT_MODE}`\"),\n    }\n}\n\nfn parse_optional_chain_bound(\n    params: &Params,\n    key: &str,\n    target_instrument_id: InstrumentId,\n) -> anyhow::Result<Option<InstrumentId>> {\n    let Some(raw) = params.get_str(key) else {\n        return Ok(None);\n    };\n\n    let instrument_id = InstrumentId::from_str(raw)\n        .with_context(|| format!(\"Invalid continuous future {key} for {target_instrument_id}\"))?;\n    if instrument_id.venue != target_instrument_id.venue {\n        anyhow::bail!(\n            \"Continuous future {key} venue mismatch for {target_instrument_id}: target venue {}, {key} venue {}\",\n            target_instrument_id.venue,","sourceCodeStart":472,"sourceCodeEnd":508,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/data/src/engine/requests.rs#L472-L508","documentation":"The `adjustment_mode` parameter for a continuous future request must be an integer 1-4 mapping to BackwardSpread(1), ForwardSpread(2), BackwardRatio(3), or ForwardRatio(4). Any other value (including 0, values >4, or non-integer) is rejected.","triggerScenarios":"parse_adjustment_mode receives a JSON value for `adjustment_mode` whose as_u64() is not 1, 2, 3, or 4 — e.g. 0, 5, a negative number, a string, or a float.","commonSituations":"Using 0-based enum indexing in client code (0 instead of 1-4); sending the mode name (\"backward_spread\") as a string instead of the numeric code; copying an adjustment-mode constant from another API with different numbering.","solutions":["Send the numeric code: 1=BackwardSpread, 2=ForwardSpread, 3=BackwardRatio, 4=ForwardRatio.","If sending a string, map it to the numeric enum before building the request params.","Verify the value is a JSON integer, not a string or float."],"exampleFix":"// before\njson!({\"adjustment_mode\": \"backward_spread\"})\n// after\njson!({\"adjustment_mode\": 1}) // BackwardSpread","handlingStrategy":"validation","validationCode":"assert!((1..=4).contains(&adjustment_mode), \"adjustment_mode must be 1-4\");","typeGuard":"fn is_valid_adjustment_mode(v: u64) -> bool { (1..=4).contains(&v) }","tryCatchPattern":null,"preventionTips":["Use a named enum with ToPrimitive instead of raw ints","Remember the mapping is 1-based: 1=BackwardSpread..4=ForwardRatio","Never send the mode as a string"],"tags":["validation","enum","continuous-futures"],"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-14T00:17:10.932Z"}