{"record":{"id":"cb5b6c96642c43b9","repo":"nautechsystems/nautilus_trader","slug":"all-total-event-slug-requests-failed","errorCode":null,"errorMessage":"All {total} event slug requests failed","messagePattern":"All (.+?) event slug requests failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/http/gamma.rs","lineNumber":703,"sourceCode":"\n        let results = futures_util::future::join_all(futures).await;\n\n        let total = results.len();\n        let succeeded = results.iter().filter(|r| r.is_some()).count();\n        let mut instruments = Vec::new();\n\n        for result in results.into_iter().flatten() {\n            let (slug, events) = result;\n            let markets = flatten_event_markets(events);\n            if markets.is_empty() {\n                log::warn!(\"No markets found in event slug '{slug}'\");\n                continue;\n            }\n            instruments.extend(parse_markets_to_instruments(&markets, ts_init));\n        }\n\n        if succeeded == 0 && total > 0 {\n            anyhow::bail!(\"All {total} event slug requests failed\");\n        }\n\n        log::debug!(\n            \"Parsed {} instruments from event slug queries\",\n            instruments.len()\n        );\n        Ok(instruments)\n    }\n\n    /// Fetches instruments using arbitrary Gamma API query params with auto-pagination.\n    pub async fn request_instruments_by_params(\n        &self,\n        base_params: GetGammaMarketsParams,\n    ) -> anyhow::Result<Vec<InstrumentAny>> {\n        let markets = self.fetch_gamma_markets_paginated(base_params).await?;\n        let ts_init = self.clock.get_time_ns();\n        let instruments = parse_markets_to_instruments(&markets, ts_init);\n        log::debug!(\"Parsed {} instruments from params query\", instruments.len());","sourceCodeStart":685,"sourceCodeEnd":721,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/http/gamma.rs#L685-L721","documentation":"request_instruments_by_event_slugs fetches Gamma markets for a batch of event slugs and counts how many slug requests succeeded. If every request in the batch failed (succeeded == 0) while at least one slug was requested, it aborts with this error instead of returning an empty instrument set. This guards against silently treating a total API outage or bad slugs as 'no instruments'.","triggerScenarios":"Calling fetch_instruments or fetch_configured_instruments where every event slug query to the Polymarket Gamma API fails (network errors, non-200 responses, or unparseable bodies) while total > 0.","commonSituations":"Polymarket API outage or rate limiting; wrong or expired event slugs in adapter config; no network access / DNS failure in a container; Gamma API URL misconfigured via environment variables.","solutions":["Verify network connectivity and that the Gamma API endpoint URL is correct/reachable (curl the endpoint).","Check the event slugs passed to fetch_instruments/fetch_configured_instruments are valid, current Polymarket event slugs.","Check logs for the per-slug error just above the bail to identify the underlying HTTP failure (auth, 429, 404).","Add retry/backoff around the slug requests if failures are transient (rate limits, temporary outages)."],"exampleFix":"// before: single shot per slug request\nlet resp = client.get(url).send()?;\n// after: retry transient failures\nlet resp = client.get(url).send()?;\nlet resp = match resp.error_for_status() {\n    Ok(r) => r,\n    Err(e) if attempt < 3 => { sleep(backoff); continue; }\n    Err(e) => return Err(e.into()),\n};","handlingStrategy":"retry","validationCode":"// precondition check before calling fetch_instruments\nassert!(!event_slugs.is_empty(), \"no event slugs configured\");\n// optionally probe the API first\nlet health = reqwest::get(\"https://gamma-api.polymarket.com/events?limit=1\").await?;\nif !health.status().is_success() { return Err(\"gamma api unreachable\".into()); }","typeGuard":null,"tryCatchPattern":"match adapter.fetch_instruments().await {\n    Ok(instruments) => instruments,\n    Err(e) if e.to_string().contains(\"All \") && e.to_string().contains(\"failed\") => {\n        log::warn!(\"gamma api batch failed entirely; retrying with backoff\");\n        backoff_retry(|| adapter.fetch_instruments()).await?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Monitor Gamma API health/uptime before starting the adapter.","Validate configured event slugs against the API at startup.","Use exponential backoff with jitter for slug requests."],"tags":["network","http","polymarket","instruments"],"backgroundTag":"http-request-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"}