nautechsystems/nautilus_trader · error

Invalid

Error message

Invalid {label} '{value}': {e}

What it means

Betfair config validation for optional market start-time strings: when a value is present it must parse as a Betfair timestamp; parse_betfair_timestamp failures are re-raised as 'Invalid {label} ...' including the underlying parse error.

Solutions

  1. Format the value exactly as parse_betfair_timestamp expects (Betfair ISO-style timestamp)
  2. Check the inner {e} message for the precise parse failure position
  3. Omit the field entirely if you don't need a market start time filter

Example fix

// before
market_start_time = "2026-09-08 09:00"
// after
market_start_time = "2026-09-08T09:00:00.000Z"
Defensive patterns

Strategy: validation

Validate before calling

// Rust
// Mirror the adapter's parser before building config
if let Some(ts) = &cfg.market_start_time {
    parse_betfair_timestamp(ts).expect("invalid Betfair timestamp");
}

Try / catch

match validate(&config) {
    Ok(c) => c,
    Err(e) => { eprintln!("config invalid: {e:#}"); std::process::exit(2); }
}

Prevention

When it happens

Trigger: Providing a non-empty market_start_time-like config field whose string does not match the expected Betfair timestamp format (wrong layout, timezone suffix, or garbage text).

Common situations: Hand-writing dates in local format, missing the required ISO/UTC layout, or copying times from other APIs with different formats.

Related errors


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

Appendix: source

Thrown at crates/adapters/betfair/src/config.rs:56

};

fn parse_currency(code: &str) -> anyhow::Result<Currency> {
    code.parse::<Currency>()
        .map_err(|_| anyhow::anyhow!("Invalid account currency code: {code}"))
}

fn make_min_notional(value: Option<Decimal>, currency: Currency) -> anyhow::Result<Option<Money>> {
    value
        .map(|amount| Money::from_decimal(amount, currency))
        .transpose()
        .map_err(Into::into)
}

fn validate_market_start_time(label: &str, value: &Option<String>) -> anyhow::Result<()> {
    if let Some(value) = value {
        parse_betfair_timestamp(value)
            .map(|_| ())
            .map_err(|e| anyhow::anyhow!("Invalid {label} '{value}': {e}"))?;
    }

    Ok(())
}

fn resolve_credential(
    username: Option<SecretString>,
    password: Option<SecretString>,
    app_key: Option<SecretString>,
) -> anyhow::Result<BetfairCredential> {
    match BetfairCredential::resolve(
        username.map(SecretString::into_inner),
        password.map(SecretString::into_inner),
        app_key.map(SecretString::into_inner),
    ) {
        Ok(Some(credential)) => Ok(credential),
        Ok(None) => anyhow::bail!("Missing Betfair credentials in config and environment"),
        Err(e) => Err(match e {

View on GitHub (pinned to 18893faf8b)