nautechsystems/nautilus_trader · error · anyhow::Error

Custom data type "{type_name}" is not registered for Arrow e

Error message

Custom data type "{type_name}" is not registered for Arrow encoding; call register_custom_data_class or ensure_custom_data_registered before writing

What it means

Thrown when encode_custom_to_arrow returns None because the custom data type was never registered for Arrow encoding. NautilusTrader requires every custom data class to be registered (register_custom_data_class / ensure_custom_data_registered) before it can be written to the catalog, since encoding depends on a per-type registered encoder.

Source

Thrown at crates/persistence/src/backend/custom.rs:155

    };

    let type_name = first_custom.data.type_name();
    let identifier = first_custom.data_type.identifier().map(String::from);
    let dt_meta = first_custom.data_type.metadata_string_map();
    let data_type_json = first_custom
        .data_type
        .to_persistence_json()
        .map_err(|e| anyhow::anyhow!("Failed to serialize data_type for persistence: {e}"))?;

    let start_ts = first_custom.data.ts_init();
    let end_ts = data.last().map_or(start_ts, |custom| custom.data.ts_init());
    let items: Vec<Arc<dyn CustomDataTrait>> =
        data.into_iter().map(|c| Arc::clone(&c.data)).collect();

    let batch = encode_custom_to_arrow(type_name, &items)
        .map_err(|e| anyhow::anyhow!("Failed to encode custom data to Arrow: {e}"))?
        .ok_or_else(|| {
            anyhow::anyhow!(
                "Custom data type \"{type_name}\" is not registered for Arrow encoding; \
                 call register_custom_data_class or ensure_custom_data_registered before writing"
            )
        })?;
    let batch =
        augment_batch_with_data_type_column(&batch, &data_type_json, type_name, dt_meta.as_ref())?;

    Ok((batch, type_name.to_string(), identifier, start_ts, end_ts))
}

/// Decodes a `RecordBatch` to Data objects based on metadata.
///
/// Supports both standard data types and custom data types when `allow_custom_fallback`
/// is true (e.g. when decoding files under `custom/`). When false, unknown type names
/// produce an error instead of attempting custom decode.
///
/// # Errors
///

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Call register_custom_data_class (or ensure_custom_data_registered) for the type before writing, at application startup.
  2. Ensure the registration runs in the same process/runtime that performs the catalog write.
  3. Verify the type_name used for the write exactly matches the registered type name string.
  4. Register types defensively in a shared init module that all writers import.

Example fix

// before
catalog.write_data(custom_items)?; // type never registered
// after
nautilus_persistence::ensure_custom_data_registered::<MyCustomData>();
catalog.write_data(custom_items)?;
Defensive patterns

Strategy: validation

Validate before calling

anyhow::ensure!(is_custom_data_registered(type_name), "register {type_name} before writing");

Type guard

fn is_registered(type_name: &str) -> bool { get_custom_data_encoder(type_name).is_some() }

Try / catch

match encode_custom_to_arrow(type_name, &items) {
    Ok(None) => { register_custom_data_class::<MyData>(); retry()? }
    Ok(Some(b)) => proceed(b),
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Calling write_custom_data_batch with a custom data type_name that has no registered encoder in the current process — registration was skipped, done in a different process/module, or the type_name string does not match the registered name.

Common situations: Loading data from disk or a worker process where the registration code never ran; renaming a data type class so type_name no longer matches the registration; forgetting to call register_custom_data_class during application startup before catalog writes.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


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