nautechsystems/nautilus_trader · error · anyhow::Error

Invalid DEX name '{}' (case-insensitive). Chain '{}' is not

Error message

Invalid DEX name '{}' (case-insensitive). Chain '{}' is not supported for pool syncing.

What it means

Thrown by run_sync_dex when the DEX name does not match any DEX registered for the resolved chain and the chain has no supported DEXes for pool syncing at all. Raised before any RPC or database connection is made.

Source

Thrown at crates/cli/src/blockchain/sync.rs:44

use nautilus_model::defi::chain::Chain;

use crate::opt::DatabaseConfig;

pub(crate) async fn run_sync_dex(
    chain: String,
    dex: String,
    rpc_url: Option<String>,
    database: DatabaseConfig,
    reset: bool,
    multicall_calls_per_rpc_request: Option<u32>,
) -> anyhow::Result<()> {
    let chain = Chain::from_chain_name(&chain)
        .ok_or_else(|| anyhow::anyhow!("Invalid chain name: {chain}"))?;

    let dex_type = find_dex_type_case_insensitive(&dex, chain).ok_or_else(|| {
        let supported_dexes = get_supported_dexes_for_chain(chain.name);
        if supported_dexes.is_empty() {
            anyhow::anyhow!("Invalid DEX name '{}' (case-insensitive). Chain '{}' is not supported for pool syncing.",dex, chain.name)
        } else {
            anyhow::anyhow!("Invalid DEX name '{}' (case-insensitive). Supported DEXes for chain '{}': {}",dex,chain.name,supported_dexes.join(", "))
        }
    })?;

    // Fail before connecting to the RPC/database when the DEX cannot discover pools from
    // PoolCreated logs; without a parser sync-dex would otherwise find zero pools silently.
    let dex_extended = get_dex_extended(chain.name, &dex_type).ok_or_else(|| {
        anyhow::anyhow!(
            "DEX '{dex_type}' is not registered on chain '{}'",
            chain.name
        )
    })?;

    if !dex_extended.supports_pool_discovery() {
        anyhow::bail!(
            "DEX '{dex_type}' on chain '{}' cannot be synced: missing a PoolCreated parser for pool discovery.",
            chain.name

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Switch to a chain that supports pool syncing (non-empty supported DEX list).
  2. Correct the DEX name; matching is case-insensitive so fix spelling.
  3. List valid DEXes with get_supported_dexes_for_chain(chain.name) before running.
  4. Register the DEX for the chain if it should be supported.

Example fix

// before
nautilusctl blockchain sync-dex --chain sepolia --dex uniswap-v2
// after
nautilusctl blockchain sync-dex --chain ethereum --dex uniswap-v2
Defensive patterns

Strategy: validation

Validate before calling

let supported = get_supported_dexes_for_chain(chain.name);
if supported.is_empty() {
    eprintln!("chain '{}' not supported for pool syncing", chain.name);
    std::process::exit(2);
}

Prevention

When it happens

Trigger: run_blockchain_command -> run_sync_dex with a --dex value failing find_dex_type_case_insensitive while get_supported_dexes_for_chain(chain.name) is empty (chain unsupported for pool syncing).

Common situations: Targeting a chain with no sync-capable DEX registry entries; typo in DEX name on an otherwise-unsupported chain; copying a sync command written for a different chain.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/dad435e7d0754c42. Report an issue: GitHub.