nautechsystems/nautilus_trader · error · anyhow::Error
Cannot extract condition_id from symbol '{symbol}': no '-' s
Error message
Cannot extract condition_id from symbol '{symbol}': no '-' separator What it means
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.
Source
Thrown at crates/adapters/polymarket/src/providers.rs:591
series_id: Some(series_ids),
active: Some(true),
closed: Some(false),
..Default::default()
}
}
/// Extracts the condition ID from an instrument symbol.
///
/// Polymarket instrument symbols follow the pattern `{condition_id}-{token_id}`.
/// The condition_id is a hex string (e.g. `0xabc123...`) and the token_id is a
/// large decimal number. This extracts the condition_id by splitting at the last `-`.
pub fn extract_condition_id(instrument_id: &InstrumentId) -> anyhow::Result<String> {
let symbol = instrument_id.symbol.as_str();
symbol
.rfind('-')
.map(|idx| symbol[..idx].to_string())
.ok_or_else(|| {
anyhow::anyhow!("Cannot extract condition_id from symbol '{symbol}': no '-' separator")
})
}
/// Extracts the token ID from an instrument symbol.
///
/// Polymarket instrument symbols follow the pattern `{condition_id}-{token_id}`. This extracts the
/// token_id by splitting at the last `-`.
pub(crate) fn extract_token_id(instrument_id: &InstrumentId) -> anyhow::Result<String> {
let symbol = instrument_id.symbol.as_str();
symbol
.rsplit_once('-')
.map(|(_, token_id)| token_id.to_string())
.ok_or_else(|| {
anyhow::anyhow!("Cannot extract token_id from symbol '{symbol}': no '-' separator")
})
}
/// Builds validated market keyset parameters from string key/value filters.View on GitHub (pinned to 18893faf8b)
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.
Example fix
// before
let condition_id = extract_condition_id(&instrument_id)?;
// after
if !instrument_id.symbol.as_str().contains('-') {
anyhow::bail!("not a Polymarket symbol: {}", instrument_id.symbol);
}
let condition_id = extract_condition_id(&instrument_id)?; Defensive patterns
Strategy: validation
Validate before calling
fn symbol_has_condition_id(instrument_id: &InstrumentId) -> bool {
instrument_id.symbol.as_str().contains('-')
} Type guard
fn split_polymarket_symbol(symbol: &str) -> Option<(String, String)> {
symbol.rsplit_once('-').map(|(c, t)| (c.to_string(), t.to_string()))
} Try / catch
match extract_condition_id(&instrument_id) {
Ok(cid) => cid,
Err(e) => { debug!("not a Polymarket symbol: {e}"); return Ok(()); }
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- Cannot extract token_id from symbol '{symbol}': no '-' separ
- invalid signed E18 integer for {field}: {value}
- Empty book snapshot for {instrument_id}
- Failed to parse clob_token_ids '{}': {e}
- Failed to parse outcomes '{}': {e}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/51ad9f9d16252eff.
Report an issue: GitHub.