{"record":{"id":"c0136ceef17c61e3","repo":"block/buzz","slug":"invalid-relay-key-e","errorCode":null,"errorMessage":"invalid relay key: {e}","messagePattern":"invalid relay key: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/buzz-admin/src/main.rs","lineNumber":495,"sourceCode":") -> Result<()> {\n    use buzz_core::kind::KIND_NIP29_GROUP_ADMINS;\n    use buzz_db::event::EventQuery;\n\n    let db = connect_db().await?;\n\n    // Resolve relay signing key: arg > env > ephemeral. Force-republish must\n    // never use an ephemeral key because it replaces an existing authoritative\n    // snapshot.\n    let configured_relay_key =\n        relay_key_arg.or_else(|| std::env::var(\"BUZZ_RELAY_PRIVATE_KEY\").ok());\n    if channel_arg.is_some() && configured_relay_key.is_none() {\n        return Err(anyhow::anyhow!(\n            \"--channel requires --relay-key or BUZZ_RELAY_PRIVATE_KEY\"\n        ));\n    }\n    let relay_keys = match configured_relay_key {\n        Some(key_hex) => {\n            Keys::parse(&key_hex).map_err(|e| anyhow::anyhow!(\"invalid relay key: {e}\"))?\n        }\n        None => {\n            let k = Keys::generate();\n            eprintln!(\n                \"Warning: no relay key provided — using ephemeral key {}\",\n                k.public_key().to_hex()\n            );\n            eprintln!(\"Events signed with this key won't be verifiable after this run.\");\n            eprintln!(\"Pass --relay-key or set BUZZ_RELAY_PRIVATE_KEY for production use.\");\n            k\n        }\n    };\n\n    let tenant = resolve_admin_tenant(&db).await?;\n    let target_channel = channel_arg\n        .as_deref()\n        .map(uuid::Uuid::parse_str)\n        .transpose()","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/block/buzz/blob/f956e6fe06a76e50cbd8fba1a162482e752e7f1a/crates/buzz-admin/src/main.rs#L477-L513","documentation":"reconcile_channels() found a relay key (from --relay-key or BUZZ_RELAY_PRIVATE_KEY) but nostr's Keys::parse() rejected the value. It must decode to a valid secp256k1 secret key — 64 hex chars or bech32 nsec1… — so wrong length, stray characters, an npub (public key), or quoting artifacts make the parse fail. The parse error is appended as {e}. This is the reconcile-channels twin of the invalid BUZZ_RELAY_PRIVATE_KEY error in add-member/remove-member.","triggerScenarios":"Passing `--relay-key npub1…` (public key), a key with a 0x prefix, a value shell-quoted with embedded quotes (`--relay-key '\"abc\"'`), or a truncated copy-paste; or BUZZ_RELAY_PRIVATE_KEY holding the same kinds of malformed values when --relay-key is omitted.","commonSituations":"Secrets copied from a password manager with whitespace/newlines; .env line wraps splitting the key; operator pastes the relay's PUBLIC key because it is the one shown in relay logs.","solutions":["Check length/charset: 64 hex chars (or full nsec1… string), no whitespace, quotes, or 0x prefix — `echo -n \"$KEY\" | wc -c` → 64.","Make sure it is the SECRET key (hex/nsec), not the npub public key.","Re-copy the exact value from the relay configuration and pass it via a shell variable to avoid quoting damage: `--relay-key \"$BUZZ_RELAY_PRIVATE_KEY\"`.","If it still fails, print the parse suffix {e} — it names the exact malformation (bad bech32 checksum, invalid hex, wrong length)."],"exampleFix":"# before\nbuzz-admin reconcile-channels --relay-key 0x8a2f...   # 0x prefix rejected\n\n# after\nbuzz-admin reconcile-channels --relay-key 8a2f...            # bare 64-hex secret","handlingStrategy":"validation","validationCode":"# validate whatever key source reconcile will use\nkey=\"${RELAY_KEY_ARG:-${BUZZ_RELAY_PRIVATE_KEY:-}}\"\nif ! [[ \"$key\" =~ ^([0-9a-fA-F]{64}|nsec1[02-9ac-hj-np-z]+)$ ]]; then\n  echo \"relay key must be 64-hex or nsec1 bech32\" >&2; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass keys via shell variables, never inline literals, to avoid quoting corruption.","Validate key shape in the same script that builds the command (see validation snippet)."],"tags":["buzz-admin","nostr","key-parsing","cli-arguments","configuration"],"backgroundTag":"invalid-key-format","analyzedSha":"f956e6fe06a76e50cbd8fba1a162482e752e7f1a","analyzedAt":"2026-08-16T22:11:40.750Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}