{"record":{"id":"36e645b671d31398","repo":"block/buzz","slug":"failed-to-build-setup-nudge-e","errorCode":null,"errorMessage":"failed to build setup nudge: {e}","messagePattern":"failed to build setup nudge: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/buzz-acp/src/setup_mode.rs","lineNumber":674,"sourceCode":"        // Top-level event: reply to the triggering event.\n        Some(ThreadRef {\n            root_event_id: triggering_event.id,\n            parent_event_id: triggering_event.id,\n        })\n    };\n\n    let body = payload.nudge_body();\n\n    let event_builder = buzz_sdk::build_message(\n        channel_id,\n        &body,\n        thread_ref.as_ref(),\n        &[recipient_hex], // p-tag the verified effective asker\n        false,\n        &[],\n        &[],\n    )\n    .map_err(|e| anyhow::anyhow!(\"failed to build setup nudge: {e}\"))?;\n\n    let signed = event_builder\n        .sign_with_keys(keys)\n        .map_err(|e| anyhow::anyhow!(\"failed to sign setup nudge: {e}\"))?;\n\n    publisher\n        .publish_event(signed)\n        .await\n        .map_err(|e| anyhow::anyhow!(\"failed to publish setup nudge: {e}\"))?;\n\n    Ok(())\n}\n\n// ── Tests ─────────────────────────────────────────────────────────────────────\n\n#[cfg(test)]\nmod tests {\n    use super::*;","sourceCodeStart":656,"sourceCodeEnd":692,"githubUrl":"https://github.com/block/buzz/blob/dad5a33865fc81a2e55b3b60746632f615ec1e3a/crates/buzz-acp/src/setup_mode.rs#L656-L692","documentation":"publish_setup_nudge builds and signs a Nostr event for the setup nudge via the SDK event builder. If the builder fails (map_err on the build result), it wraps the cause as 'failed to build setup nudge: {e}'. nudge_authorized_event propagates this to the caller as an anyhow error.","triggerScenarios":"The buzz-sdk event builder returns an error while constructing the nudge event — invalid tag inputs (e.g. malformed recipient pubkey hex), or builder validation failures for kind/content constraints.","commonSituations":"Upstream produced a recipient pubkey that is not valid hex or wrong length; a refactor changed the builder signature/tag expectations; SDK version change tightened event validation.","solutions":["Log and inspect the wrapped cause `{e}` — it names the exact builder failure","Validate the recipient pubkey is 64-char lowercase hex before building the event","Check the event builder call matches the current buzz-sdk EventBuilder API after upgrades","Return a typed error to the caller instead of relying on anyhow string context"],"exampleFix":"// before\n.map_err(|e| anyhow::anyhow!(\"failed to build setup nudge: {e}\"))?;\n// after\nlet pubkey = secp256k1::XOnlyPublicKey::from_str(&recipient_hex)\n    .context(\"invalid recipient pubkey for setup nudge\")?;\n// ... then build with the parsed key","handlingStrategy":"validation","validationCode":"fn valid_pubkey_hex(s: &str) -> bool {\n    s.len() == 64 && s.bytes().all(|b| b.is_ascii_hexdigit())\n}\n// call before building the nudge event\nif !valid_pubkey_hex(&recipient_hex) { bail!(\"bad recipient pubkey\"); }","typeGuard":"null","tryCatchPattern":"match publish_setup_nudge(...).await {\n    Ok(_) => {},\n    Err(e) => tracing::error!(error = ?e, \"setup nudge publish failed\"),\n} // inspect the wrapped builder cause in logs","preventionTips":["Validate recipient pubkeys are canonical 64-char hex before event construction","Pin and review buzz-sdk EventBuilder API when upgrading","Return typed errors instead of anyhow strings for builder failures"],"tags":["rust","nostr","event-builder","validation"],"backgroundTag":"event-build-failed","analyzedSha":"dad5a33865fc81a2e55b3b60746632f615ec1e3a","analyzedAt":"2026-09-05T18:13:50.666Z","contentChangedAt":"2026-09-05T18:13:50.666Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}