{"record":{"id":"e46e262fe8d18981","repo":"moghtech/komodo","slug":"invalid-container-state","errorCode":null,"errorMessage":"Invalid container state: {}","messagePattern":"Invalid container state: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"client/core/rs/src/entities/docker/container.rs","lineNumber":344,"sourceCode":"  #[default]\n  #[serde(rename = \"\")]\n  #[strum(serialize = \"\")]\n  Empty,\n}\n\nimpl ::std::str::FromStr for ContainerStateStatusEnum {\n  type Err = anyhow::Error;\n  fn from_str(s: &str) -> Result<Self, Self::Err> {\n    match s {\n      \"\" => Ok(ContainerStateStatusEnum::Empty),\n      \"created\" => Ok(ContainerStateStatusEnum::Created),\n      \"running\" => Ok(ContainerStateStatusEnum::Running),\n      \"paused\" => Ok(ContainerStateStatusEnum::Paused),\n      \"restarting\" => Ok(ContainerStateStatusEnum::Restarting),\n      \"removing\" => Ok(ContainerStateStatusEnum::Removing),\n      \"exited\" => Ok(ContainerStateStatusEnum::Exited),\n      \"dead\" => Ok(ContainerStateStatusEnum::Dead),\n      x => Err(anyhow!(\"Invalid container state: {}\", x)),\n    }\n  }\n}\n\n/// Health stores information about the container's healthcheck results.\n#[typeshare]\n#[derive(\n  Debug, Clone, Default, PartialEq, Serialize, Deserialize,\n)]\n#[cfg_attr(feature = \"utoipa\", derive(utoipa::ToSchema))]\npub struct ContainerHealth {\n  /// Status is one of `none`, `starting`, `healthy` or `unhealthy`  - \\\"none\\\"      Indicates there is no healthcheck - \\\"starting\\\"  Starting indicates that the container is not yet ready - \\\"healthy\\\"   Healthy indicates that the container is running correctly - \\\"unhealthy\\\" Unhealthy indicates that the container has a problem\n  #[serde(default, rename = \"Status\")]\n  pub status: HealthStatusEnum,\n\n  /// FailingStreak is the number of consecutive failures\n  #[serde(rename = \"FailingStreak\")]\n  pub failing_streak: Option<I64>,","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/moghtech/komodo/blob/780ac68b992094a9fccd5fffb760e0c84fd3c3d1/client/core/rs/src/entities/docker/container.rs#L326-L362","documentation":"ContainerStateStatusEnum::from_str converts a Docker-reported container state string into the enum. If the string is not one of running/paused/restarting/removing/exited/dead, it fails with anyhow, embedding the offending string in the message. This guards against unknown or malformed state values coming from Docker.","triggerScenarios":"Deserializing a container state string that is not one of the six known values, e.g. an empty string, whitespace, capitalized text like 'Running', or a state newly introduced by a Docker engine version.","commonSituations":"Parsing Docker inspect/API responses from a newer Docker Engine that emits a state the client SDK doesn't know; accidentally passing a status (e.g. 'created', 'Up 2 minutes') instead of a state enum string.","solutions":["Log the exact string shown in the error message and compare against the supported set: running, paused, restarting, removing, exited, dead","Normalize input to lowercase and trim whitespace before calling from_str","Check Docker Engine version; if it reports a new state, update/patch the Komodo client enum to support it","Map legacy states like 'created' to a supported variant before parsing"],"exampleFix":"// before\nlet state = ContainerStateStatusEnum::from_str(raw)?;\n// after\nlet state = ContainerStateStatusEnum::from_str(raw.trim().to_lowercase().as_str())\n    .or_else(|_| match raw.trim().to_lowercase().as_str() {\n        \"created\" => Ok(ContainerStateStatusEnum::Exited), // legacy mapping\n        other => Err(anyhow!(\"unmapped container state: {other}\")),\n    })?;","handlingStrategy":"validation","validationCode":"const VALID: [&str; 6] = [\"running\",\"paused\",\"restarting\",\"removing\",\"exited\",\"dead\"];\nfn is_valid_state(s: &str) -> bool { VALID.contains(&s.trim().to_lowercase().as_str()) }\nif !is_valid_state(raw) { return Err(anyhow!(\"unsupported container state: {raw}\")); }","typeGuard":"fn is_known_state(s: &str) -> bool {\n    matches!(s.trim().to_lowercase().as_str(), \"running\"|\"paused\"|\"restarting\"|\"removing\"|\"exited\"|\"dead\")\n}","tryCatchPattern":null,"preventionTips":["Normalize state strings (trim + lowercase) before parsing","Keep the client's container-state enum in sync with your Docker Engine version","Treat unknown states as a parse warning, not a crash, in monitoring code"],"tags":["docker","parsing","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"780ac68b992094a9fccd5fffb760e0c84fd3c3d1","analyzedAt":"2026-09-08T10:02:44.861Z","contentChangedAt":"2026-09-08T10:02:44.861Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}