{"record":{"id":"7ad1f7fa5819901c","repo":"nautechsystems/nautilus_trader","slug":"custom-data-type-type-name-is-already-register-7ad1f7","errorCode":null,"errorMessage":"Custom data type \"{type_name}\" is already registered for Arrow","messagePattern":"Custom data type \"(.+?)\" is already registered for Arrow","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/model/src/data/registry.rs","lineNumber":169,"sourceCode":"    };\n    Ok(Some(Data::Custom(custom)))\n}\n\n/// Registers Arrow schema, encoder, and decoder for the given custom data type name.\n///\n/// # Errors\n/// Returns an error if the type is already registered for Arrow.\n#[cfg(feature = \"arrow\")]\npub fn register_arrow(\n    type_name: &str,\n    schema: Arc<Schema>,\n    encoder: ArrowEncoder,\n    decoder: ArrowDecoder,\n) -> Result<(), anyhow::Error> {\n    let reg = registries();\n    match reg.arrow.entry(type_name.to_string()) {\n        Entry::Occupied(_) => {\n            anyhow::bail!(\"Custom data type \\\"{type_name}\\\" is already registered for Arrow\");\n        }\n        Entry::Vacant(v) => {\n            v.insert((schema, encoder, decoder));\n            Ok(())\n        }\n    }\n}\n\n/// Registers Arrow schema, encoder, and decoder for the given custom data type name if not already\n/// registered. If the type is already registered, returns `Ok(())` without overwriting (idempotent).\n/// Use this where repeated registration can occur (e.g. module init).\n///\n/// # Errors\n/// Does not return an error (idempotent insert into `DashMap`).\n#[cfg(feature = \"arrow\")]\npub fn ensure_arrow_registered(\n    type_name: &str,\n    schema: Arc<Schema>,","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/data/registry.rs#L151-L187","documentation":"register_arrow inserts an Arrow schema/encoder/decoder triple into the custom-data registry keyed by type name. Duplicate type names are rejected with this error rather than overwriting an existing registration, keeping the Arrow encode/decode path deterministic.","triggerScenarios":"Calling register_arrow twice with the same type_name — repeated initialization, module re-import in Python, or two crates registering Arrow support for the same type.","commonSituations":"Test suites running registration per test; notebook re-runs; adapter reload logic that lacks an idempotence guard.","solutions":["Make registration idempotent (Once lock, checked init, or catch-and-ignore this specific error when the registration is identical).","Ensure the encoder/decoder/schema setup runs exactly once per process.","Rename the type if a genuine conflict between different types exists."],"exampleFix":"// before\nregister_arrow(\"MyData\", schema, enc, dec)?;\n// after\nif let Err(e) = register_arrow(\"MyData\", schema, enc, dec) {\n    if !e.to_string().contains(\"already registered\") { return Err(e); }\n}","handlingStrategy":"try-catch","validationCode":"// Rust — guard with process-wide init\nstatic ARROW_INIT: OnceLock<()> = OnceLock::new();\n// call inside: ARROW_INIT.get_or_init(|| register_arrow(name, schema, enc, dec).unwrap());","typeGuard":null,"tryCatchPattern":"// Rust\nmatch register_arrow(type_name, schema, enc, dec) {\n    Ok(()) => (),\n    Err(e) if e.to_string().contains(\"already registered for Arrow\") => (), // treat as success\n    Err(e) => return Err(e),\n}","preventionTips":["Wrap Arrow registration in a Once-style initializer so repeats are no-ops.","In tests, register in a setup function that runs once, or tolerate duplicates.","Document ownership of each type's Arrow registration to avoid cross-crate collisions."],"tags":["registry","arrow","duplicate-registration"],"backgroundTag":"file-already-exists","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}