TryBugHunt

The Zombie Dead-Letter Resurrection

Hardpython

Message Header Mutation & Pre-Ack Dead-Letter Guarantee

0:00
Step 1: Test Traffic & Expose Flaw
"""
Queue Job Consumer
Polls messages, executes worker tasks, and manages retry / DLQ lifecycle.
"""

class QueueConsumer:
    def __init__(self, broker, policy):
        self.broker = broker
        self.policy = policy

    def handle_message(self, message, handler_fn):
        msg_id = message["id"]
        try:
            handler_fn(message["payload"])
            self.broker.ack(msg_id)
            return {"status": "PROCESSED", "message_id": msg_id}
        except Exception as err:
            decision = self.policy.track_attempt(message)
            if decision["can_retry"]:
                # Re-queue message for next retry cycle
                return {"status": "RETRY_QUEUED", "message_id": msg_id, "attempt": decision["attempt"]}
            else:
                # Retries exhausted
                # AI BUG: ACKs message BEFORE confirming DLQ dispatch!
                self.broker.ack(msg_id)
                self.broker.route_to_dlq(message, str(err))
                return {"status": "DEAD_LETTERED", "message_id": msg_id, "attempt": decision["attempt"]}
Step 1: Test Traffic & Expose Flaw

Run the worker poll simulation with a poison-pill payload. Prove that the message retries infinitely and never routes to the Dead Letter Queue.

Choose Traffic Scenario to TestClick to simulate
Architectural Guide & Interview Notes
↑ Jump to Interactive Studio

Deep Dive: The Zombie Dead-Letter Resurrection

An engineering analysis of why this AI-generated Pull Request passed isolated unit tests, how multi-tenant traffic exposes the architectural flaw, and how interviewers score your response.

The Root Cause Anti-Pattern

The Interviewer's Scoring Rubric

Candidates are assessed on whether they jump to trial-and-error editing or follow a hypothesis-driven approach. A "Strong Hire" candidate restates the data flow between modules, explains why single-client unit tests passed, crafts an adversarial probe showing cross-tenant leakage, and implements a surgical 1-line patch without breaking existing contracts.

Candidate Strategy for the Code Comprehension Round

  1. 1Map Module ContractsTrace how the gateway invokes the underlying service. Note what data is passed by reference vs. by value.
  2. 2Break It With An Adversarial ProbeSimulate concurrent or sequential traffic across multiple identities to force shared state mutation.
  3. 3Deliver a Surgical PatchMake the minimal required diff to ensure proper per-client state isolation without refactoring unnecessary files.