nautechsystems/nautilus_trader · error
Duplicate
Error message
Duplicate {description} What it means
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.
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
Example fix
// before ensure_distinct(["https://a.example", "https://a.example"], "provider endpoint")?; // after let endpoints: Vec<&str> = raw_endpoints.iter().map(|e| e.as_str()).collect::<HashSet<_>>().into_iter().collect(); ensure_distinct(endpoints, "provider endpoint")?;
Defensive patterns
Strategy: validation
Validate before calling
let set: HashSet<&str> = values.iter().copied().collect();
if set.len() != values.len() {
return Err(format!("duplicate values in {description}: {:?}", values));
} Try / catch
match ensure_distinct(endpoints, "provider endpoint") {
Err(e) => { eprintln!("config check failed: {e:#}"); dedupe_and_retry(); }
Ok(()) => proceed(),
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Deployment manifest contains a duplicate token identity
- Allowed token pair -> is not fully pinned by the deployment…
- Binance instrument filter
- Binance load_ids value
- Binance US market data requires spot_market_data_mode=Json
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/b74dc561313286ba.
Report an issue: GitHub.
Appendix: source
Thrown at crates/adapters/blockchain/src/rpc/verification.rs:1462
&& identity
.failure_domain_ids
.iter()
.all(|domain| !domain.trim().is_empty()),
"Provider failure domains must contain nonempty opaque IDs"
);
ensure_distinct(
identity.failure_domain_ids.iter().map(String::as_str),
"failure-domain IDs within one provider",
)
}
fn ensure_distinct<'a>(
values: impl IntoIterator<Item = &'a str>,
description: &str,
) -> anyhow::Result<()> {
let values = values.into_iter().collect::<Vec<_>>();
let unique = values.iter().copied().collect::<HashSet<_>>();
anyhow::ensure!(values.len() == unique.len(), "Duplicate {description}");
Ok(())
}
fn normalize_endpoint(endpoint: &str) -> anyhow::Result<String> {
let url = validate_execution_endpoint(endpoint, "Provider")?;
Ok(url.to_string())
}
fn decode_simulation<T>(
result: anyhow::Result<RpcCallResult>,
decode: impl Fn(&[u8]) -> anyhow::Result<T>,
) -> anyhow::Result<VerifiedSimulation<T>> {
match result? {
RpcCallResult::Success(bytes) => decode(&bytes).map(VerifiedSimulation::Succeeded),
RpcCallResult::Reverted => Ok(VerifiedSimulation::Denied),
}
}
View on GitHub (pinned to 18893faf8b)