{"record":{"id":"5995a6441e051124","repo":"nautechsystems/nautilus_trader","slug":"pool-identifier-must-be-42-chars-address-or-66-c","errorCode":null,"errorMessage":"Pool identifier must be 42 chars (address) or 66 chars (pool ID), was {len} chars: {value}","messagePattern":"Pool identifier must be 42 chars \\(address\\) or 66 chars \\(pool ID\\), was (.+?) chars: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/model/src/defi/pool_identifier.rs","lineNumber":92,"sourceCode":"                validate_hex_string(value)?;\n\n                // Parse without strict checksum validation, then normalize to checksummed format\n                let addr = value\n                    .parse::<Address>()\n                    .map_err(|e| anyhow::anyhow!(\"Invalid address: {e}\"))?;\n\n                // Store the checksummed version\n                Ok(Self::Address(Ustr::from(addr.to_checksum(None).as_str())))\n            }\n            66 => {\n                // PoolId variant (32 bytes)\n                validate_hex_string(value)?;\n\n                // Store lowercase version for consistency\n                Ok(Self::PoolId(Ustr::from(&value.to_lowercase())))\n            }\n            len => {\n                anyhow::bail!(\n                    \"Pool identifier must be 42 chars (address) or 66 chars (pool ID), was {len} chars: {value}\"\n                )\n            }\n        }\n    }\n\n    /// Creates a new [`PoolIdentifier`] instance.\n    ///\n    /// # Panics\n    ///\n    /// Panics if validation fails.\n    #[must_use]\n    pub fn new<T: AsRef<str>>(value: T) -> Self {\n        Self::new_checked(value).expect(FAILED)\n    }\n\n    /// Creates an Address variant from an alloy Address.\n    ///","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/defi/pool_identifier.rs#L74-L110","documentation":"PoolIdentifier::new_checked only accepts identifiers of exactly 42 characters (an EVM address) or 66 characters (a 32-byte V4 pool ID), both with 0x prefix and valid hex. Any other length is rejected. This enforces the two canonical pool identifier shapes the model layer supports.","triggerScenarios":"Calling PoolIdentifier::new_checked with a string whose length is not 42 or 66 — e.g. a truncated hex string, an address missing '0x' (40 chars), a pool ID without '0x' (64 chars), or arbitrary pool names/symbols.","commonSituations":"Config files or venue parameters holding a shortened or unprefixed address; passing a Uniswap V3 fee-tier name or pool label instead of an on-chain identifier; slicing errors when copying pool IDs from explorers.","solutions":["Count the characters of the value and ensure it is exactly 42 or 66 including the '0x' prefix","Add the '0x' prefix if missing (an unprefixed 40-char address or 64-char pool ID fails)","Verify you are passing an on-chain identifier, not a human-readable pool name or symbol","Use PoolIdentifier::new_address or from_pool_id_hex helpers which make the intended variant explicit"],"exampleFix":"// before\nlet pid = PoolIdentifier::new_checked(\"a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\")?;\n// after\nlet pid = PoolIdentifier::new_checked(\"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\")?; // 42 chars","handlingStrategy":"validation","validationCode":"fn is_valid_pool_identifier(s: &str) -> bool {\n    let len = s.len();\n    (len == 42 || len == 66) && s.starts_with(\"0x\") && s[2..].chars().all(|c| c.is_ascii_hexdigit())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always store pool identifiers with the 0x prefix","Assert length 42 or 66 at config-load time","Never pass human-readable pool names to PoolIdentifier"],"tags":["rust","validation","defi","hex"],"backgroundTag":"invalid-argument-format","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"}