{"record":{"id":"ca14ea4c57455dae","repo":"nautechsystems/nautilus_trader","slug":"cannot-extract-token-id-from-symbol-symbol-no","errorCode":null,"errorMessage":"Cannot extract token_id from symbol '{symbol}': no '-' separator","messagePattern":"Cannot extract token_id from symbol '(.+?)': no '-' separator","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/providers.rs","lineNumber":605,"sourceCode":"    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.\n///\n/// # Errors\n///\n/// Returns an error for unknown keys, malformed values, or invalid filter combinations.\npub fn build_gamma_params_from_hashmap(\n    map: &HashMap<String, String>,\n) -> anyhow::Result<GetGammaMarketsParams> {\n    for key in map.keys() {\n        match key.as_str() {\n            \"is_active\"\n            | \"active\"\n            | \"closed\"\n            | \"archived\"\n            | \"id\"","sourceCodeStart":587,"sourceCodeEnd":623,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/providers.rs#L587-L623","documentation":"extract_token_id splits the symbol at the last '-' via rsplit_once and returns the trailing token id. Since Polymarket symbols are {condition_id}-{token_id}, a symbol without any '-' cannot yield a token id and triggers this error.","triggerScenarios":"Calling extract_token_id with an InstrumentId whose symbol has no '-' separator — e.g. a raw condition_id without a token suffix, or a symbol created outside the Polymarket factory.","commonSituations":"Constructing instrument ids by hand in tests or scripts, mixing venues' instrument ids, or stripping the token suffix accidentally with string manipulation.","solutions":["Build the InstrumentId from the Polymarket instrument definition so the symbol keeps the {condition_id}-{token_id} form.","Check symbol.contains('-') before calling extract_token_id.","Trace the InstrumentId's origin — likely a non-Polymarket instrument reached provider code."],"exampleFix":"// before\nlet token_id = extract_token_id(&instrument_id)?;\n// after\nlet symbol = instrument_id.symbol.as_str();\nlet token_id = match symbol.rsplit_once('-') {\n    Some((_, tid)) => tid.to_string(),\n    None => return Ok(()), // not a Polymarket instrument; skip\n};","handlingStrategy":"type-guard","validationCode":"fn symbol_has_token_id(instrument_id: &InstrumentId) -> bool {\n    instrument_id.symbol.as_str().rsplit_once('-').map_or(false, |(_, t)| !t.is_empty())\n}","typeGuard":"fn polymarket_token_id(instrument_id: &InstrumentId) -> Option<String> {\n    instrument_id.symbol.as_str().rsplit_once('-').map(|(_, t)| t.to_string())\n}","tryCatchPattern":"match extract_token_id(&instrument_id) {\n    Ok(tid) => tid,\n    Err(e) => { debug!(\"skipping non-Polymarket symbol: {e}\"); return Ok(()); }\n}","preventionTips":["Never strip the -{token_id} suffix when manipulating symbols.","Derive InstrumentIds from the instrument factory rather than string concatenation by hand.","Add a guard that skips non-Polymarket-shaped symbols in subscription bookkeeping."],"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"}