{"record":{"id":"51ad9f9d16252eff","repo":"nautechsystems/nautilus_trader","slug":"cannot-extract-condition-id-from-symbol-symbol","errorCode":null,"errorMessage":"Cannot extract condition_id from symbol '{symbol}': no '-' separator","messagePattern":"Cannot extract condition_id from symbol '(.+?)': no '-' separator","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/providers.rs","lineNumber":591,"sourceCode":"        series_id: Some(series_ids),\n        active: Some(true),\n        closed: Some(false),\n        ..Default::default()\n    }\n}\n\n/// Extracts the condition ID from an instrument symbol.\n///\n/// Polymarket instrument symbols follow the pattern `{condition_id}-{token_id}`.\n/// The condition_id is a hex string (e.g. `0xabc123...`) and the token_id is a\n/// large decimal number. This extracts the condition_id by splitting at the last `-`.\npub fn extract_condition_id(instrument_id: &InstrumentId) -> anyhow::Result<String> {\n    let symbol = instrument_id.symbol.as_str();\n    symbol\n        .rfind('-')\n        .map(|idx| symbol[..idx].to_string())\n        .ok_or_else(|| {\n            anyhow::anyhow!(\"Cannot extract condition_id from symbol '{symbol}': no '-' separator\")\n        })\n}\n\n/// Extracts the token ID from an instrument symbol.\n///\n/// Polymarket instrument symbols follow the pattern `{condition_id}-{token_id}`. This extracts the\n/// token_id by splitting at the last `-`.\npub(crate) fn extract_token_id(instrument_id: &InstrumentId) -> anyhow::Result<String> {\n    let symbol = instrument_id.symbol.as_str();\n    symbol\n        .rsplit_once('-')\n        .map(|(_, token_id)| token_id.to_string())\n        .ok_or_else(|| {\n            anyhow::anyhow!(\"Cannot extract token_id from symbol '{symbol}': no '-' separator\")\n        })\n}\n\n/// Builds validated market keyset parameters from string key/value filters.","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/providers.rs#L573-L609","documentation":"Polymarket instrument symbols follow the pattern {condition_id}-{token_id}. extract_condition_id splits the symbol at the last '-' and returns everything before it; this error is thrown when the symbol contains no '-' separator at all, so a condition_id cannot be recovered.","triggerScenarios":"Calling extract_condition_id (directly or via resume_resolution_subscriptions, queue_pending_load, ensure_auto_load_task, etc.) with an InstrumentId whose symbol lacks a '-', e.g. a manually constructed symbol or one from a different adapter's naming convention.","commonSituations":"Hardcoded or test instrument ids not built via the Polymarket instrument factory, symbols from other venues leaking into Polymarket subscription code, or truncated symbol strings.","solutions":["Ensure the InstrumentId was created from a Polymarket instrument definition so the symbol is {condition_id}-{token_id}.","Validate the symbol contains '-' before calling extract_condition_id.","Check where the InstrumentId originates — a non-Polymarket instrument is likely being routed into Polymarket provider logic."],"exampleFix":"// before\nlet condition_id = extract_condition_id(&instrument_id)?;\n// after\nif !instrument_id.symbol.as_str().contains('-') {\n    anyhow::bail!(\"not a Polymarket symbol: {}\", instrument_id.symbol);\n}\nlet condition_id = extract_condition_id(&instrument_id)?;","handlingStrategy":"validation","validationCode":"fn symbol_has_condition_id(instrument_id: &InstrumentId) -> bool {\n    instrument_id.symbol.as_str().contains('-')\n}","typeGuard":"fn split_polymarket_symbol(symbol: &str) -> Option<(String, String)> {\n    symbol.rsplit_once('-').map(|(c, t)| (c.to_string(), t.to_string()))\n}","tryCatchPattern":"match extract_condition_id(&instrument_id) {\n    Ok(cid) => cid,\n    Err(e) => { debug!(\"not a Polymarket symbol: {e}\"); return Ok(()); }\n}","preventionTips":["Create InstrumentIds only from Polymarket instrument definitions.","Route instruments from other adapters to their own providers before calling Polymarket helpers.","Unit test symbol helpers with a missing-separator case."],"tags":["rust","parsing","identifier","polymarket"],"backgroundTag":"invalid-identifier-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"}