Skip to content

refactor(selfhost): remove or wire the dead checkAndMarkDelivery helper #2506

Description

@JSONbored

Parent: #1936

Problem

checkAndMarkDelivery (the documented webhook-delivery-dedup helper in src/selfhost/redis-cache.ts) is exported but never called anywhere in src/. The real webhook dedup path in src/server.ts implements its own get-then-set inline instead of using it: it directly calls webhookCache!.get(\delivery:${deliveryId}`)/webhookCache!.set(`delivery:${deliveryId}`, "1", 300), duplicating (with a deliberate mark-after-success ordering difference) the exact logic checkAndMarkDelivery` already provides.

checkAndMarkDelivery has zero call sites, so it is unreachable dead code that still ships, still gets maintained/reviewed, and creates two divergent implementations of the same dedup logic that can silently drift out of sync (e.g. a future TTL or key-prefix change applied to one and not the other).

Fix

Either:

  1. Delete checkAndMarkDelivery from redis-cache.ts — its logic is superseded by the inline implementation in server.ts, which additionally has the correct mark-only-after-success semantics that checkAndMarkDelivery lacks, OR
  2. Refactor server.ts's inline block to call it directly so there is one source of truth for webhook delivery dedup (would require first fixing checkAndMarkDelivery's mark-timing to match the correct mark-after-success behavior).

Option 1 is the smaller, safer change given the inline version is already correct and live.

Verification

  • Confirm checkAndMarkDelivery still has zero call sites against current src/ (line numbers may have shifted).
  • Whichever option is chosen, confirm test coverage for webhook delivery dedup still passes unchanged.

Metadata

Metadata

Assignees

Labels

maintainer-onlyOwner-only work — yields no Gittensor points.

Projects

Status
Done

Relationships

None yet

Development

No branches or pull requests

Issue actions