{"record":{"id":"68b8bc18dd807cd3","repo":"block/buzz","slug":"target-event-not-found","errorCode":null,"errorMessage":"target event not found","messagePattern":"target event not found","errorType":"validation","errorClass":"IngestError::Rejected","httpStatus":null,"severity":"error","filePath":"crates/buzz-relay/src/handlers/side_effects.rs","lineNumber":263,"sourceCode":"        let target_pubkey_bytes =\n            hex::decode(parts[1]).map_err(|_| anyhow::anyhow!(\"invalid pubkey in a-tag\"))?;\n        if target_pubkey_bytes != actor_bytes\n            && !state\n                .db\n                .is_agent_owner(tenant.community(), &target_pubkey_bytes, &actor_bytes)\n                .await?\n        {\n            return Err(anyhow::anyhow!(\"must be event author\"));\n        }\n        return Ok(());\n    }\n\n    for target_id in target_ids {\n        let target_event = state\n            .db\n            .get_event_by_id_including_deleted(tenant.community(), &target_id)\n            .await?\n            .ok_or_else(|| anyhow::anyhow!(\"target event not found\"))?;\n\n        let target_author =\n            effective_message_author(&target_event.event, &state.relay_keypair.public_key());\n        if target_author != actor_bytes\n            && !state\n                .db\n                .is_agent_owner(tenant.community(), &target_author, &actor_bytes)\n                .await?\n        {\n            return Err(anyhow::anyhow!(\"must be event author\"));\n        }\n    }\n\n    Ok(())\n}\n\n/// Returns `true` if `actor_bytes` is the NIP-OA owner of **any** active owner-role\n/// member in `members`. Used by kind:9002 and kind:9008 to authorize the owning","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/block/buzz/blob/f956e6fe06a76e50cbd8fba1a162482e752e7f1a/crates/buzz-relay/src/handlers/side_effects.rs#L245-L281","documentation":"An 'e'-tag deletion referenced a well-formed 64-hex event id, but get_event_by_id_including_deleted() found no such event in this community — the lookup includes soft-deleted rows, so the target was never stored here (or was hard-purged). Deletions can only target events the relay actually holds; a deletion for an id the relay has never seen cannot be authorized or applied.","triggerScenarios":"e tag id has a typo/case error or is a truncated 64-char string; the target event lives on a different relay or in a different community (tenant fence); the event was hard-deleted by retention/purge; the id is a placeholder (all zeros) from test fixtures.","commonSituations":"Client fetched an id from a federated/other-community UI and tries to delete locally; copy-paste corruption of the hex id; event ids from an old environment when pointing the client at a fresh relay database.","solutions":["Verify the target id by fetching it first (POST /query or a get_event_by_id style lookup) in the same community","Re-copy the id from the event you actually want deleted — compare all 64 hex chars","If the target is addressable, switch to an 'a' tag deletion which authorizes by coordinate without a row lookup","If testing against a fresh environment, re-publish the target event before deleting it"],"exampleFix":"// before: publish deletion for an id that was never stored here\nEventBuilder::new(Kind::EventDeletion, \"\", [Tag::event(unknown_id)]).to_event(&keys)\n// → \"target event not found\"\n\n// after: confirm the event exists in this community, then delete\nlet hit = client.query(vec![Filter::new().id(target_id)]).await?;\nassert!(!hit.is_empty(), \"target not in this community\");\nEventBuilder::new(Kind::EventDeletion, \"\", [Tag::event(target_id)]).to_event(&keys)","handlingStrategy":"validation","validationCode":"// Pre-flight each e-tag target against this community before publishing\nfor id in target_ids {\n    let id = EventId::from_hex(&id)?;\n    let exists = client.get_event_by_id(community, id).await?.is_some();\n    anyhow::ensure!(exists, \"target {id} not stored in this community — refusing to publish\");\n}","typeGuard":"const isWellFormedEventId = (v: string): boolean =>\n  v.length === 64 && /^[0-9a-f]+$/i.test(v);","tryCatchPattern":"match validate_standard_deletion_event(&tenant, &event, &state).await {\n    Err(e) if e.to_string().contains(\"target event not found\") => {\n        // drop the unknown ids from the e-tag list and re-sign once; a missing target will never appear later\n        prune_missing_targets_and_republish(&event).await\n    }\n    other => other,\n}","preventionTips":["Source e-tag ids from events you fetched from the same relay/community, never from cross-environment UIs","Batch deletions defensively: one bad id rejects the whole event, so verify every id first","For addressable targets prefer a-tag deletions, which authorize by coordinate without a row lookup"],"tags":["nostr","nip-09","deletion","not-found","validation"],"backgroundTag":"nip09-deletion-target-not-found","analyzedSha":"f956e6fe06a76e50cbd8fba1a162482e752e7f1a","analyzedAt":"2026-08-16T22:11:40.750Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}