{"record":{"id":"c1b03ce7f46e0ea1","repo":"nautechsystems/nautilus_trader","slug":"either-contracts-or-instrument-ids-must-be-provide","errorCode":null,"errorMessage":"Either contracts or instrument_ids must be provided","messagePattern":"Either contracts or instrument_ids must be provided","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/historical/client.rs","lineNumber":256,"sourceCode":"        }\n\n        if let Some(start) = start_date_time\n            && start >= end_date_time\n        {\n            anyhow::bail!(\"Start date must be before end date\");\n        }\n\n        if let Some(duration) = duration {\n            duration.parse::<historical::Duration>().with_context(|| {\n                format!(\"duration must be in format: 'int S|D|W|M|Y', was '{duration}'\")\n            })?;\n        }\n\n        let contracts = contracts.unwrap_or_default();\n        let instrument_ids = instrument_ids.unwrap_or_default();\n\n        if contracts.is_empty() && instrument_ids.is_empty() {\n            anyhow::bail!(\"Either contracts or instrument_ids must be provided\");\n        }\n\n        // Convert instrument IDs to contracts using instrument provider\n        let mut all_contracts = contracts;\n\n        for instrument_id in instrument_ids {\n            // Try to find instrument in provider first\n            if self.instrument_provider.find(&instrument_id).is_none() {\n                // Auto-fetch if not cached\n                if let Err(e) = self\n                    .instrument_provider\n                    .fetch_contract_details(&self.ib_client, instrument_id, false, None)\n                    .await\n                {\n                    tracing::warn!(\n                        \"Failed to auto-fetch contract details for {}: {}\",\n                        instrument_id,\n                        e","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/historical/client.rs#L238-L274","documentation":"request_bars requires at least one way to identify the instruments to fetch: a list of IB Contract objects or a list of Nautilus InstrumentIds. If both are absent or empty, no history request could be formed, so the client bails.","triggerScenarios":"Calling request_bars with contracts=None and instrument_ids=None, or with empty vectors for both (they are unwrap_or_default-ed).","commonSituations":"An upstream filter produced zero instruments; a config list left empty; a wrapper that passes its own (possibly empty) Option straight through after having consumed the ids elsewhere.","solutions":["Pass at least one InstrumentId in instrument_ids (e.g. \"EUR/USD.IDEALPRO\").","Pass a non-empty Vec<Contract> if you already hold IB contracts.","Check the upstream filter/config that produced the empty list and populate it."],"exampleFix":"// before\nlet ids: Vec<InstrumentId> = Vec::new();\nclient.request_bars(&[\"1-HOUR-LAST\"], end, None, Some(\"5 D\"), None, Some(ids), true, 60).await?;\n// after\nlet ids = vec![InstrumentId::from(\"EUR/USD.IDEALPRO\")];\nclient.request_bars(&[\"1-HOUR-LAST\"], end, None, Some(\"5 D\"), None, Some(ids), true, 60).await?;","handlingStrategy":"validation","validationCode":"if contracts.as_ref().map_or(true, |c| c.is_empty())\n    && instrument_ids.as_ref().map_or(true, |i| i.is_empty()) {\n    return Err(\"no instruments selected for bar request\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the instrument universe is non-empty at config load time.","Fail fast in wrappers instead of forwarding empty Option<Vec<_>>."],"tags":["missing-argument","validation","rust","historical-data"],"backgroundTag":"missing-required-argument","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"}