{"record":{"id":"b74dc561313286ba","repo":"nautechsystems/nautilus_trader","slug":"duplicate-description","errorCode":null,"errorMessage":"Duplicate {description}","messagePattern":"Duplicate (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/rpc/verification.rs","lineNumber":1462,"sourceCode":"            && identity\n                .failure_domain_ids\n                .iter()\n                .all(|domain| !domain.trim().is_empty()),\n        \"Provider failure domains must contain nonempty opaque IDs\"\n    );\n    ensure_distinct(\n        identity.failure_domain_ids.iter().map(String::as_str),\n        \"failure-domain IDs within one provider\",\n    )\n}\n\nfn ensure_distinct<'a>(\n    values: impl IntoIterator<Item = &'a str>,\n    description: &str,\n) -> anyhow::Result<()> {\n    let values = values.into_iter().collect::<Vec<_>>();\n    let unique = values.iter().copied().collect::<HashSet<_>>();\n    anyhow::ensure!(values.len() == unique.len(), \"Duplicate {description}\");\n    Ok(())\n}\n\nfn normalize_endpoint(endpoint: &str) -> anyhow::Result<String> {\n    let url = validate_execution_endpoint(endpoint, \"Provider\")?;\n    Ok(url.to_string())\n}\n\nfn decode_simulation<T>(\n    result: anyhow::Result<RpcCallResult>,\n    decode: impl Fn(&[u8]) -> anyhow::Result<T>,\n) -> anyhow::Result<VerifiedSimulation<T>> {\n    match result? {\n        RpcCallResult::Success(bytes) => decode(&bytes).map(VerifiedSimulation::Succeeded),\n        RpcCallResult::Reverted => Ok(VerifiedSimulation::Denied),\n    }\n}\n","sourceCodeStart":1444,"sourceCodeEnd":1480,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/rpc/verification.rs#L1444-L1480","documentation":"This error comes from the ensure_distinct helper in verification.rs, which verifies that a set of string values contains no duplicates before registering provider endpoints or identifiers. The format string interpolates the human-readable description of what is being checked, so the final message reads e.g. 'Duplicate provider endpoint'. It prevents ambiguous or conflicting provider data from entering verification state.","triggerScenarios":"Calling any code path that invokes ensure_distinct with an iterator containing two equal strings — e.g. a provider registering the same normalized endpoint twice, or repeating an ID in a list.","commonSituations":"Copy-pasted endpoint URLs in provider config; the same endpoint listed under multiple failure domains; config merge logic that concatenates lists without deduplication; trailing-slash/case variants that are duplicates in intent but distinct only if normalization was skipped.","solutions":["Deduplicate the value list before passing it to the validation path (e.g. HashSet or .dedup() on a sorted Vec)","Check provider config for repeated endpoints/IDs and remove the duplicates","Normalize endpoints first (validate_execution_endpoint) and dedupe on the normalized form","Report which value is duplicated to the user for easier config debugging"],"exampleFix":"// before\nensure_distinct([\"https://a.example\", \"https://a.example\"], \"provider endpoint\")?;\n// after\nlet endpoints: Vec<&str> = raw_endpoints.iter().map(|e| e.as_str()).collect::<HashSet<_>>().into_iter().collect();\nensure_distinct(endpoints, \"provider endpoint\")?;","handlingStrategy":"validation","validationCode":"let set: HashSet<&str> = values.iter().copied().collect();\nif set.len() != values.len() {\n    return Err(format!(\"duplicate values in {description}: {:?}\", values));\n}","typeGuard":null,"tryCatchPattern":"match ensure_distinct(endpoints, \"provider endpoint\") {\n    Err(e) => { eprintln!(\"config check failed: {e:#}\"); dedupe_and_retry(); }\n    Ok(()) => proceed(),\n}","preventionTips":["Deduplicate lists when merging config sources","Normalize endpoints (URL canonicalization) before dedupe checks","Deduplicate on normalized forms so trailing-slash/case variants are caught","Unit-test config merge logic with duplicated entries"],"tags":["validation","duplicates","config"],"backgroundTag":"schema-validation-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}