Skip to main content

priv/templates/parapet.gen.runbooks/dead_letter.ex.eex

defmodule <%= inspect(@module_prefix) %>.DeadLetter do
  use Parapet.Runbook

  title("Dead Letter Queue Recovery")
  description("Guidance and recovery actions for items that have permanently failed processing.")

  step(:investigate_error,
    label: "Analyze Error Reason",
    description: "Check the last error message for why the item was dead lettered.",
    type: :manual,
    kind: :guidance,
    preview_only: true,
    guidance: "Review the attached exception and stacktrace. Identify whether the failure is transient (e.g. network timeout) or structural (e.g. schema mismatch, bad payload). Proceed to requeue only if the root cause is understood and resolved.",
    warning: "Do not requeue if the error indicates a persistent structural failure — reprocessing will dead-letter the item again immediately."
  )

  step(:requeue_item,
    label: "Requeue Item",
    description: "Move the item out of the dead letter queue to be processed again.",
    type: :mitigation,
    kind: :capability,
    capability: :requeue_dead_letter,
    target_kind: :async_item,
    requires_preview: true,
    warning: "Requeued items will be re-processed from the start. Confirm the item's operation is idempotent or that any partial side effects from the original attempt have been reversed."
  )

  step(:verify_recovery,
    label: "Verify Recovery",
    description: "Confirm the item processed successfully after requeue.",
    type: :manual,
    kind: :guidance,
    preview_only: true,
    guidance: "Check the item's status in the job backend — it should no longer appear in the dead letter queue. Verify any expected downstream effects (database writes, notifications, etc.) completed successfully."
  )
end