{"record":{"id":"124d81328240c7f0","repo":"nautechsystems/nautilus_trader","slug":"container-id-missing","errorCode":null,"errorMessage":"Container ID missing","messagePattern":"Container ID missing","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/gateway/dockerized.rs","lineNumber":305,"sourceCode":"                .unwrap_or(false)\n        });\n\n        let Some(container) = container else {\n            return Ok(ContainerStatus::NoContainer);\n        };\n\n        let state = container\n            .state\n            .as_ref()\n            .map(|state| state.as_ref())\n            .unwrap_or(\"unknown\");\n\n        match state {\n            \"running\" => {\n                let container_id = container\n                    .id\n                    .as_ref()\n                    .ok_or_else(|| anyhow::anyhow!(\"Container ID missing\"))?;\n\n                if self.is_logged_in(container_id).await.unwrap_or(false) {\n                    Ok(ContainerStatus::Ready)\n                } else {\n                    Ok(ContainerStatus::ContainerStarting)\n                }\n            }\n            \"stopped\" | \"exited\" => Ok(ContainerStatus::ContainerStopped),\n            \"created\" => Ok(ContainerStatus::ContainerCreated),\n            _ => Ok(ContainerStatus::Unknown),\n        }\n    }\n\n    /// Start the gateway container.\n    ///\n    /// # Arguments\n    ///\n    /// * `wait` - Optional wait time in seconds (overrides config timeout)","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/gateway/dockerized.rs#L287-L323","documentation":"container_status inspects the gateway container's state via the Docker API and, when the container reports 'running', reads its container.id to check login status. The bollard API models id as optional; if Docker returns a running container without an id, this error is raised because login checks and subsequent management require the id. This is an unexpected Docker API response rather than a gateway misconfiguration.","triggerScenarios":"Calling container_status (directly or via start) when the Docker API returns a container in 'running' state whose `id` field is None — typically a transient/inconsistent Docker daemon response or an API/serialization quirk.","commonSituations":"Race during rapid start/stop cycles where the daemon's inspect data is momentarily incomplete; older Docker daemon versions or socket proxying that drop fields; listing by filter that returns a stale/partial container struct.","solutions":["Retry container_status after a short delay — the id is usually present on the next poll.","Verify Docker daemon health and version; upgrade an outdated daemon if ids are being omitted.","Recreate the gateway container (stop/remove then start) if the container record is corrupted.","Check whether any Docker socket proxy/middleware strips fields from inspect/list responses."],"exampleFix":"// defensive caller pattern\nmatch gateway.container_status().await {\n    Ok(status) => use(status),\n    Err(e) if e.to_string().contains(\"Container ID missing\") => {\n        tokio::time::sleep(Duration::from_secs(2)).await; // retry transient Docker race\n        retry_or_recreate_container();\n    }\n    Err(e) => return Err(e),\n}","handlingStrategy":"retry","validationCode":"let container = containers.first().ok_or(\"no gateway container\")?;\nif container.state.as_deref() == Some(\"running\") && container.id.is_none() {\n    // transient incomplete response — skip this poll and retry\n}","typeGuard":"fn has_id(container: &Container) -> bool {\n    container.id.is_some()\n}","tryCatchPattern":"for attempt in 0..3 {\n    match gateway.container_status().await {\n        Ok(status) => break status,\n        Err(e) if e.to_string().contains(\"Container ID missing\") && attempt < 2 => {\n            tokio::time::sleep(Duration::from_secs(2)).await;\n        }\n        Err(e) => return Err(e),\n    }\n}","preventionTips":["Avoid rapid start/stop/start cycles that race the Docker daemon's inspect data","Keep the Docker daemon current and healthy","Poll container_status on an interval instead of immediately after start","Recreate the container if 'Container ID missing' repeats across retries"],"tags":["docker","container","internal-state","race-condition"],"backgroundTag":"unexpected-api-response-shape","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"}