{"record":{"id":"8e57c74ecbd19bd3","repo":"zellij-org/zellij","slug":"invalid-barekey-value","errorCode":null,"errorMessage":"Invalid BareKey value: {}","messagePattern":"Invalid BareKey value: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"zellij-utils/src/ipc/enum_conversions.rs","lineNumber":127,"sourceCode":"    fn try_from(modifier: ProtoKeyModifier) -> Result<Self> {\n        match modifier {\n            ProtoKeyModifier::Ctrl => Ok(KeyModifier::Ctrl),\n            ProtoKeyModifier::Alt => Ok(KeyModifier::Alt),\n            ProtoKeyModifier::Shift => Ok(KeyModifier::Shift),\n            ProtoKeyModifier::Super => Ok(KeyModifier::Super),\n            ProtoKeyModifier::Unspecified => Err(anyhow!(\"Unspecified key modifier\")),\n        }\n    }\n}\n\n// Helper functions for converting between protobuf i32 and enum types\npub fn bare_key_to_proto_i32(key: BareKey) -> i32 {\n    ProtoBareKey::from(key) as i32\n}\n\npub fn bare_key_from_proto_i32(value: i32) -> Result<BareKey> {\n    let proto_key =\n        ProtoBareKey::from_i32(value).ok_or_else(|| anyhow!(\"Invalid BareKey value: {}\", value))?;\n    proto_key.try_into()\n}\n\npub fn key_modifier_to_proto_i32(modifier: KeyModifier) -> i32 {\n    ProtoKeyModifier::from(modifier) as i32\n}\n\npub fn key_modifier_from_proto_i32(value: i32) -> Result<KeyModifier> {\n    let proto_modifier = ProtoKeyModifier::from_i32(value)\n        .ok_or_else(|| anyhow!(\"Invalid KeyModifier value: {}\", value))?;\n    proto_modifier.try_into()\n}\n","sourceCodeStart":109,"sourceCodeEnd":140,"githubUrl":"https://github.com/zellij-org/zellij/blob/5cb5df5cce4e16c5d1c57c7c062e4a90a7823c41/zellij-utils/src/ipc/enum_conversions.rs#L109-L140","documentation":"Thrown by bare_key_from_proto_i32 (zellij-utils/src/ipc/enum_conversions.rs) when ProtoBareKey::from_i32 returns None, i.e. the raw i32 in the message is not a valid BareKey discriminant. This is strictly an out-of-range value, distinct from the in-range Unspecified case [74].","triggerScenarios":"key.bare_key contains an integer outside the enum's range: version skew where a newer zellij adds key variants an older binary does not know, handcrafted/corrupted IPC frames, or code computing the discriminant incorrectly instead of using bare_key_to_proto_i32.","commonSituations":"Client and server from different zellij releases sharing a session; custom web/native clients hardcoding numeric values; partially corrupted protobuf payloads.","solutions":["Match zellij versions on both sides of the IPC boundary (same release for client, server, and plugins).","Always derive discriminants with `BareKey::X as i32` / bare_key_to_proto_i32, never magic numbers.","Validate inbound i32 values with ProtoBareKey::from_i32(...).is_some() before converting, and drop/log invalid frames."],"exampleFix":"// before\nlet key = bare_key_from_proto_i32(999)?; // Err(\"Invalid BareKey value: 999\")\n\n// after: validate, then convert\nif ProtoBareKey::from_i32(raw).is_some() {\n    let key = bare_key_from_proto_i32(raw)?;\n}","handlingStrategy":"validation","validationCode":"// validate the raw discriminant before converting\nif ProtoBareKey::from_i32(raw).is_none() {\n    log::warn!(\"dropping frame with unknown BareKey {raw} (version skew?)\");\n    return Ok(None);\n}\nlet key = bare_key_from_proto_i32(raw)?;","typeGuard":"fn is_known_bare_key(v: i32) -> bool {\n    ProtoBareKey::from_i32(v).is_some()\n}","tryCatchPattern":"match bare_key_from_proto_i32(value) {\n    Ok(key) => Some(key),\n    Err(e) if e.to_string().starts_with(\"Invalid BareKey value\") => {\n        log::warn!(\"unknown BareKey discriminant {value}; frame dropped\");\n        None\n    },\n    Err(e) => return Err(e),\n}","preventionTips":["Pin client, server, and plugins to the same zellij release so enum ranges match.","Generate discriminants only via `BareKey::X as i32` / bare_key_to_proto_i32 — never literals.","Tolerate-and-log unknown discriminants at boundaries so older binaries degrade instead of erroring."],"tags":["zellij","rust","protobuf","ipc","enum-conversion","version-skew"],"backgroundTag":"invalid-enum-value","analyzedSha":"5cb5df5cce4e16c5d1c57c7c062e4a90a7823c41","analyzedAt":"2026-08-19T07:42:58.758Z","contentChangedAt":"2026-08-19T07:42:58.758Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}