{"record":{"id":"feb0f6c2ba1dbdd3","repo":"nautechsystems/nautilus_trader","slug":"provider-condition-condition-id-does-not-match-i","errorCode":null,"errorMessage":"provider condition {condition_id} does not match instrument condition {instrument_condition}","messagePattern":"provider condition (.+?) does not match instrument condition (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/adapters/polymarket/src/execution/reconciliation.rs","lineNumber":252,"sourceCode":"        trade_id,\n    })\n}\n\nfn validate_instrument_binding(\n    instrument: &InstrumentAny,\n    condition_id: &str,\n    outcome: PolymarketOutcome,\n) -> anyhow::Result<()> {\n    let InstrumentAny::BinaryOption(binary) = instrument else {\n        anyhow::bail!(\"expected Polymarket BinaryOption instrument, found {instrument:?}\");\n    };\n    let instrument_condition = binary\n        .info\n        .as_ref()\n        .and_then(|info| info.get_str(\"condition_id\"))\n        .context(\"Polymarket instrument is missing condition_id metadata\")?;\n\n    anyhow::ensure!(\n        instrument_condition.eq_ignore_ascii_case(condition_id),\n        \"provider condition {condition_id} does not match instrument condition {instrument_condition}\",\n    );\n    let instrument_outcome = binary\n        .outcome\n        .context(\"Polymarket instrument is missing outcome metadata\")?;\n    anyhow::ensure!(\n        instrument_outcome == outcome.as_str(),\n        \"provider outcome {outcome} does not match instrument outcome {instrument_outcome}\",\n    );\n\n    Ok(())\n}\n\nfn validate_quantity_evidence(\n    value: Decimal,\n    precision: u8,\n    field: &str,","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/reconciliation.rs#L234-L270","documentation":"Before reconciling an order or fill, the code binds the provider object to the local instrument by comparing condition_id metadata. This error fires when the condition_id from the provider (order or trade) does not match the condition_id stored in the instrument's info metadata (case-insensitively), meaning the order/fill belongs to a different market than the instrument.","triggerScenarios":"build_order_report_from_order, classify_target_trade, or build_fill_reports_from_trades -> validate_instrument_binding is called with a provider object whose condition_id differs from binary.info[\"condition_id\"].","commonSituations":"Subscribing/reconciling with an instrument built from a stale market config while the venue moved the market to a new condition_id; hardcoding or mis-copying a token/condition id in config; a market resolved and re-deployed with a new condition id.","solutions":["Print both condition_ids and confirm which is correct; refetch the market definition from Polymarket.","Rebuild the instrument from the current market metadata so info.condition_id matches the live market.","Check the instrument/venue configuration for a copied or outdated condition_id.","Verify any instrument cache is invalidated when the market is re-created or resolved."],"exampleFix":"// before\nlet instrument = load_instrument_cached(symbol)?;\nvalidate_instrument_binding(&order, &instrument)?;\n// after: refresh instrument when condition ids diverge\nlet instrument = load_instrument_cached(symbol)?;\nif !condition_matches(&order, &instrument) {\n    let instrument = reload_instrument_from_provider(symbol)?;\n    validate_instrument_binding(&order, &instrument)?;\n}","handlingStrategy":"validation","validationCode":"fn condition_matches(instrument: &Instrument, condition_id: &str) -> bool {\n    instrument.info.as_ref()\n        .and_then(|i| i.get_str(\"condition_id\"))\n        .map(|c| c.eq_ignore_ascii_case(condition_id))\n        .unwrap_or(false)\n}","typeGuard":"fn bound_to_condition(instrument: &Instrument, condition_id: &str) -> Option<&Instrument> {\n    condition_matches(instrument, condition_id).then_some(instrument)\n}","tryCatchPattern":"match validate_instrument_binding(&order, &instrument) {\n    Ok(()) => (),\n    Err(e) if e.to_string().contains(\"condition\") => reload_instrument_and_retry(&symbol)?,\n    Err(e) => return Err(e),\n}","preventionTips":["Always build instruments from live market metadata, never hardcoded condition_ids","Invalidate instrument caches when markets resolve or are re-created","Log both condition ids on mismatch for fast diagnosis"],"tags":["rust","polymarket","instrument-binding","condition-id"],"backgroundTag":"invalid-argument-value","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"}