{"record":{"id":"aac71ece2fdd0407","repo":"nautechsystems/nautilus_trader","slug":"invalid-hypersync-url","errorCode":null,"errorMessage":"Invalid HyperSync URL","messagePattern":"Invalid HyperSync URL","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/adapters/blockchain/src/hypersync/client.rs","lineNumber":109,"sourceCode":"\nimpl HyperSyncClient {\n    /// Creates a new [`HyperSyncClient`] instance for the given chain and message sender.\n    ///\n    /// # Panics\n    ///\n    /// Panics if:\n    /// - The chain's `hypersync_url` is invalid.\n    /// - The `ENVIO_API_TOKEN` environment variable is not set or invalid.\n    /// - The underlying client cannot be initialized.\n    #[must_use]\n    pub fn new(\n        chain: SharedChain,\n        tx: Option<tokio::sync::mpsc::UnboundedSender<BlockchainMessage>>,\n        cancellation_token: tokio_util::sync::CancellationToken,\n    ) -> Self {\n        let mut config = hypersync_client::ClientConfig::default();\n        let hypersync_url = validate_execution_endpoint(chain.hypersync_url.as_str(), \"HyperSync\")\n            .expect(\"Invalid HyperSync URL\");\n        config.url = hypersync_url.to_string();\n        config.api_token = std::env::var(\"ENVIO_API_TOKEN\")\n            .expect(\"ENVIO_API_TOKEN environment variable must be set\");\n\n        let client = hypersync_client::Client::new(config)\n            .expect(\"Failed to create HyperSync client - check ENVIO_API_TOKEN is a valid UUID\");\n\n        Self {\n            chain,\n            client: Arc::new(client),\n            blocks_task: TaskSlot::new(),\n            blocks_cancellation_token: None,\n            dex_event_tasks: AHashMap::new(),\n            tx,\n            pool_addresses: AHashMap::new(),\n            cancellation_token,\n        }\n    }","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/hypersync/client.rs#L91-L127","documentation":"`HypersyncClient::new` builds a `hypersync_client::ClientConfig` from the chain's `hypersync_url` and calls `.expect(\"Invalid HyperSync URL\")` on `validate_execution_endpoint`, panicking when the URL fails validation (unparseable/empty/not a valid endpoint). This code runs in a constructor that cannot return `Result`, so any misconfigured chain URL aborts the process at client construction time. It is a configuration-time failure, not a network failure.","triggerScenarios":"Constructing the HyperSync client for a `SharedChain` whose `hypersync_url` is empty, malformed (e.g. missing scheme, typo, whitespace), or otherwise rejected by `validate_execution_endpoint`.","commonSituations":"A typo'd or deprecated HyperSync endpoint in chain configuration; a custom/self-hosted HyperSync instance whose URL string is wrong; a config file or env value interpolated incorrectly leaving the URL blank.","solutions":["Fix the `hypersync_url` on the chain config to a valid, reachable endpoint URL (e.g. https://eth.hypersync.xyz).","Run the URL through `validate_execution_endpoint` (or a URL parse) in your own setup code first to get a descriptive error before client construction.","Check where the chain config is loaded — an empty or mis-interpolated value is the usual culprit.","If self-hosting HyperSync, confirm the base URL scheme and host are correct."],"exampleFix":"// before\nlet client = HypersyncClient::new(chain, tx, token); // panics if chain.hypersync_url is invalid\n// after\nlet url = validate_execution_endpoint(chain.hypersync_url.as_str(), \"HyperSync\")\n    .map_err(|e| anyhow::anyhow!(\"bad hypersync url for {}: {e}\", chain.name))?;\nlet client = HypersyncClient::new(chain, tx, token);","handlingStrategy":"validation","validationCode":"fn check_hypersync_url(chain: &SharedChain) -> Result<(), String> {\n    let url = chain.hypersync_url.trim();\n    if url.is_empty() || !url.starts_with(\"https://\") {\n        return Err(format!(\"chain {} has invalid hypersync_url: {:?}\", chain.name, url));\n    }\n    url::Url::parse(url).map(|_| ()).map_err(|e| e.to_string())\n}","typeGuard":null,"tryCatchPattern":"// Fail fast in bootstrap before constructing the client\ncheck_hypersync_url(&chain).map_err(|e| anyhow::anyhow!(e))?;","preventionTips":["Keep HyperSync URLs in one typed config struct, not scattered string literals.","Validate all endpoint URLs at config load time, before any client construction.","Watch for blank values caused by failed env interpolation in deployment templating."],"tags":["panic","rust","hypersync","configuration","url-validation"],"backgroundTag":"invalid-url","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"}