{"record":{"id":"beb7dc1cfe611ead","repo":"zeroclaw-labs/zeroclaw","slug":"channel-type-identity-cannot-be-empty","errorCode":null,"errorMessage":"{channel_type} identity cannot be empty","messagePattern":"(.+?) identity cannot be empty","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-channels/src/orchestrator/mod.rs","lineNumber":8666,"sourceCode":"pub fn bind_channel_identity_into(\n    config: &mut Config,\n    channel_type: &str,\n    alias: &str,\n    identity: &str,\n) -> Result<bool> {\n    use zeroclaw_config::multi_agent::{PeerGroupConfig, PeerUsername};\n    use zeroclaw_config::providers::ChannelRef;\n\n    let Some(normalize) = channel_identity_normalizer(channel_type) else {\n        anyhow::bail!(\n            \"Channel type `{channel_type}` does not support identity binding \\\n             (supported: telegram, wechat, line).\"\n        );\n    };\n\n    let normalized = normalize(identity);\n    if normalized.is_empty() {\n        anyhow::bail!(\"{channel_type} identity cannot be empty\");\n    }\n\n    // The alias must name an existing `[channels.<type>.<alias>]` section.\n    // Binding into a phantom alias would mint a peer group the runtime never\n    // reads (it resolves authorization per the alias the channel actually\n    // runs under), so fail loudly instead of silently authorizing nobody.\n    if !channel_alias_configured(config, channel_type, alias) {\n        anyhow::bail!(\n            \"{channel_type} channel alias `{alias}` is not configured. Run \\\n             `zeroclaw config set channels.{channel_type}.{alias}.bot_token <token>` \\\n             (see docs/book/src/channels/overview.md for the full field list).\"\n        );\n    }\n\n    let group_name = format!(\"{channel_type}_{alias}\");\n    let channel_ref = format!(\"{channel_type}.{alias}\");\n    let group = config\n        .peer_groups","sourceCodeStart":8648,"sourceCodeEnd":8684,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-channels/src/orchestrator/mod.rs#L8648-L8684","documentation":"Thrown by bind_channel_identity_into after normalizing the incoming identity: the channel-specific normalizer (trim for wechat/line, telegram numeric-id normalization) produced an empty string. A peer group entry keyed on an empty identity would match nothing (or worse, over-match), so the bind is refused.","triggerScenarios":"Calling bind_channel_identity_into with identity = \"\", a whitespace-only string, or a value the normalizer reduces to nothing (e.g. a telegram identity consisting solely of characters stripped by normalize_telegram_identity).","commonSituations":"CLI bind command invoked without the identity argument; gateway bind endpoint receives an empty payload field; shell script passes an unset variable (`$TG_ID` when it was never exported).","solutions":["Supply the real chat identity: for telegram the numeric user/chat ID, for wechat/line the non-empty username/id string","If scripting, verify the variable is set and non-empty before invoking bind","Trim obvious whitespace/quotes that may have been introduced by copy-paste"],"exampleFix":"# before\nzeroclaw bind telegram default \"$TG_ID\"   # TG_ID unset -> \"\"\n# error: telegram identity cannot be empty\n\n# after\nexport TG_ID=123456789\nzeroclaw bind telegram default \"$TG_ID\"","handlingStrategy":"validation","validationCode":"let identity = identity.trim();\nif identity.is_empty() {\n    return Ok(notify(\"identity is required for binding\"));\n}\nbind_channel_identity_into(&mut config, channel_type, alias, identity)?;","typeGuard":null,"tryCatchPattern":"Err(err) if err.to_string().contains(\"identity cannot be empty\") => {\n    // re-prompt for the numeric telegram id / wechat-line username\n}","preventionTips":["Require and validate the identity argument in CLI arg parsers before calling bind","In gateway handlers, 400 on empty identity payloads at the boundary","For telegram, validate the identity is numeric before binding"],"tags":["identity-binding","empty-value","validation","zeroclaw"],"backgroundTag":"empty-required-field","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}