{"record":{"id":"335ec799ea77a116","repo":"block/buzz","slug":"unexpected-enforcement-action-other","errorCode":null,"errorMessage":"unexpected enforcement action: {other}","messagePattern":"unexpected enforcement action: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/buzz-relay/src/handlers/report_resolution.rs","lineNumber":773,"sourceCode":"                .get_thread_metadata_by_event(ctx.community_id, target)\n                .await\n                .map_err(|e| anyhow::anyhow!(\"thread metadata lookup failed: {e}\"))?;\n            let parent_id = meta.as_ref().and_then(|m| m.parent_event_id.clone());\n            let root_id = meta.as_ref().and_then(|m| m.root_event_id.clone());\n            state\n                .db\n                .execute_delete_with_marker(\n                    action_id,\n                    lease_token,\n                    ctx.community_id,\n                    target,\n                    parent_id.as_deref(),\n                    root_id.as_deref(),\n                )\n                .await\n                .map_err(|e| anyhow::anyhow!(\"delete failed: {e}\"))\n        }\n        other => Err(anyhow::anyhow!(\"unexpected enforcement action: {other}\")),\n    };\n\n    match raw? {\n        true => Ok(MutationOutcome::Committed),\n        false => {\n            // Reload to distinguish \"step_marker already set by another driver\"\n            // (AlreadyCommitted — safe to proceed to finalization) from \"this\n            // driver's lease expired\" (LeaseLost — must stop, recovery worker\n            // will take over after expiry).\n            let rec = state\n                .db\n                .get_admin_action(action_id)\n                .await\n                .map_err(|e| anyhow::anyhow!(\"classify mutation result: {e}\"))?;\n            match rec {\n                Some(r) if r.step_marker.is_some() => Ok(MutationOutcome::AlreadyCommitted),\n                _ => Ok(MutationOutcome::LeaseLost),\n            }","sourceCodeStart":755,"sourceCodeEnd":791,"githubUrl":"https://github.com/block/buzz/blob/eed74bde2f4797714335ac10c56c0b0244c1def4/crates/buzz-relay/src/handlers/report_resolution.rs#L755-L791","documentation":"This is a dispatch exhaustiveness error in `run_atomic_mutation`: the enforcement action string in `ctx.action` matched none of the supported arms (\"ban\", \"timeout\", \"kick\", \"delete\"). It indicates the action record carries an unrecognized or corrupt action type, so the driver refuses to execute an unknown mutation rather than guessing. The `{other}` placeholder names the unexpected action value.","triggerScenarios":"An admin_actions row whose action field is something other than ban/timeout/kick/delete is fed into `drive_enforcement` — e.g. a new action kind added to the actions table without a matching match arm, a typo'd action string written at creation, or an old row from a schema/migration change.","commonSituations":"A code version mismatch where a newer relay wrote a new action type but an older binary (or the recovery worker) drives it; manual DB edits/seed rows with invalid action values; a regression in the code path that constructs EnforcementContext.","solutions":["Log/inspect the offending action value in `{other}` and find the admin_actions row that produced it.","Add a match arm for the new action type if it is a legitimately supported action.","Delete or correct the corrupt action row (and its report linkage) so the recovery worker stops re-driving it.","Ensure relay and recovery-worker binaries are the same version so action strings and match arms agree.","Validate the action string at action-creation time so unknown values are rejected before persistence."],"exampleFix":"// before\nother => Err(anyhow::anyhow!(\"unexpected enforcement action: {other}\")),\n// after: validate at creation + exhaustive arm\nif !matches!(action, \"ban\" | \"timeout\" | \"kick\" | \"delete\") {\n    return Err(anyhow::anyhow!(\"unsupported action at creation: {action}\"));\n}\n// ...and in the match:\n\"mute\" => execute_mute_with_marker(...).map_err(|e| anyhow::anyhow!(\"mute failed: {e}\")),\nother => Err(anyhow::anyhow!(\"unexpected enforcement action: {other}\")),","handlingStrategy":"validation","validationCode":"const SUPPORTED_ACTIONS: &[&str] = &[\"ban\", \"timeout\", \"kick\", \"delete\"];\nfn is_supported_action(action: &str) -> bool { SUPPORTED_ACTIONS.contains(&action) }\n// call before driving: assert!(is_supported_action(&ctx.action));","typeGuard":"fn parse_enforcement_action(s: &str) -> Option<EnforcementAction> {\n    match s {\n        \"ban\" => Some(EnforcementAction::Ban),\n        \"timeout\" => Some(EnforcementAction::Timeout),\n        \"kick\" => Some(EnforcementAction::Kick),\n        \"delete\" => Some(EnforcementAction::Delete),\n        _ => None,\n    }\n}","tryCatchPattern":"match parse_enforcement_action(&ctx.action) {\n    Some(action) => drive(action),\n    None => {\n        warn!(\"skipping unknown enforcement action '{}' for action_id {}\", ctx.action, ctx.action_id);\n        mark_action_poisoned(ctx.action_id); // so recovery worker stops re-driving\n    }\n}","preventionTips":["Model actions as an enum serialized to the DB instead of free-form strings so invalid values cannot be persisted.","Validate the action string at admin-action creation time.","Keep relay and recovery-worker deployments version-aligned.","Audit admin_actions rows after schema/migrations for stray action values."],"tags":["moderation","dispatch","exhaustiveness","rust","state-machine"],"backgroundTag":"unknown-enum-variant","analyzedSha":"eed74bde2f4797714335ac10c56c0b0244c1def4","analyzedAt":"2026-08-30T13:49:18.474Z","contentChangedAt":"2026-08-30T13:49:18.474Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}