nautechsystems/nautilus_trader · error

Invalid venue

Error message

Invalid venue

What it means

`NautilusKernelCommand::blockchain()` extracts the `Blockchain` from a DeFi command's instrument_id venue via `instrument_id.blockchain().expect("Invalid venue")`. It panics when the venue name is not a parseable blockchain venue. The method is only valid for pool-related commands whose venue encodes a chain.

Source

Thrown at crates/common/src/messages/defi/mod.rs:183

                    cmd.client_id,
                    command_id,
                    ts_init,
                    cmd.params,
                ))
            }
        }
    }

    /// Returns the blockchain associated with this command.
    ///
    /// # Panics
    ///
    /// Panics if the instrument ID's venue cannot be parsed as a valid blockchain venue
    /// for `Pool`, `PoolSwaps`, `PoolLiquidityUpdates`, `PoolFeeCollects`, or `PoolFlashEvents` commands.
    pub fn blockchain(&self) -> Blockchain {
        match self {
            Self::Blocks(cmd) => cmd.chain,
            Self::Pool(cmd) => cmd.instrument_id.blockchain().expect("Invalid venue"),
            Self::PoolSwaps(cmd) => cmd.instrument_id.blockchain().expect("Invalid venue"),
            Self::PoolLiquidityUpdates(cmd) => {
                cmd.instrument_id.blockchain().expect("Invalid venue")
            }
            Self::PoolFeeCollects(cmd) => cmd.instrument_id.blockchain().expect("Invalid venue"),
            Self::PoolFlashEvents(cmd) => cmd.instrument_id.blockchain().expect("Invalid venue"),
        }
    }

    pub fn command_id(&self) -> UUID4 {
        match self {
            Self::Blocks(cmd) => cmd.command_id,
            Self::Pool(cmd) => cmd.command_id,
            Self::PoolSwaps(cmd) => cmd.command_id,
            Self::PoolLiquidityUpdates(cmd) => cmd.command_id,
            Self::PoolFeeCollects(cmd) => cmd.command_id,
            Self::PoolFlashEvents(cmd) => cmd.command_id,
        }

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Validate `instrument_id.blockchain()` returns Some before constructing/sending the command
  2. Build instrument IDs using the Blockchain venue constructor rather than raw strings
  3. Check venue spelling/case against supported blockchain venues (e.g. Ethereum, Arbitrum, Base)
  4. Use the Blocks command (which carries `chain` directly) when possible instead of venue-derived chains

Example fix

// before
let chain = cmd.instrument_id.blockchain().expect("Invalid venue");
// after
let chain = cmd.instrument_id.blockchain()
    .ok_or_else(|| anyhow::anyhow!("invalid blockchain venue: {}", cmd.instrument_id.venue))?;
Defensive patterns

Strategy: validation

Validate before calling

if cmd.instrument_id.blockchain().is_none() {
    eprintln!("venue {} is not a blockchain", cmd.instrument_id.venue);
    return;
}

Type guard

fn is_defi_command(cmd: &NautilusKernelCommand) -> bool {
    matches!(cmd, NautilusKernelCommand::Pool(_)
        | NautilusKernelCommand::PoolSwaps(_)
        | NautilusKernelCommand::PoolLiquidityUpdates(_)
        | NautilusKernelCommand::PoolFeeCollects(_)
        | NautilusKernelCommand::PoolFlashEvents(_))
}

Prevention

When it happens

Trigger: Calling `blockchain()` on a Pool/PoolSwaps/PoolLiquidityUpdates/PoolFeeCollects/PoolFlashEvents command whose `instrument_id.venue` string does not correspond to a known blockchain venue.

Common situations: Constructing DeFi subscribe/query commands with a hand-typed or arbitrary venue (e.g. an exchange venue instead of a chain name); venue case/typo mismatch; cross-wiring trading instruments into DeFi commands.

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/528efee42d6e8831. Report an issue: GitHub.