The Silent Alert Bug: When Your Instant Push Exists but Never Fires
Your alert formatter is probably fine. The problem is that nobody calls it. The Symptom A user reports that instant push notifications stopped working. The daily report arrives on schedule. The formatting looks correct in the report. But the moment a position opens, nothing hits their phone. The first instinct is to blame the transport layer: the push service, the API key, the network. You check…
The issue at hand is not with the alert formatter itself, but rather with the fact that it is never invoked. A user reported that instant push notifications suddenly stopped working, yet the daily report was generated as usual and looked correct. The first assumption was that the problem lay within the transport layer, such as the push service, API key, or network.
However, upon testing manually, a test push was sent successfully, revealing that the problem was not with the pipeline but rather with the code responsible for invoking the push.
Upon examining the code, it was discovered that a function named `format_instant_alert` was present, which built a single-line push message for newly opened positions. This function was clean, tested, and correct for months. However, a closer inspection revealed that there were no calls to this function anywhere in the codebase. The function was essentially a dead code, as it was never invoked.
The real problem stemmed from the fact that the push notifications were wired into four separate code paths for opening positions. These paths included manual entry from the CLI, scheduled strategy execution, signal-driven entry from a webhook, and recovery/reconciliation after a restart. Each path contained copy-pasted blocks of open-position logic, along with comments stating that the push was integrated into the daily report.
This led to four separate code paths, each containing the same false assumption that the push was handled during daily report generation.
The issue here was that the comments were merely claims about code that lived somewhere else. There was no enforcement mechanism to ensure that the push was indeed handled. When the "elsewhere" changed or when it never actually handled the case, the comments remained, confidently lying. The propagation of this lie across four code paths further exacerbated the problem.
The solution to this issue was straightforward: audit for call sites, not just definitions. To find dead code, it is essential to search for how a function is used, rather than just where it is defined. By enumerating the functions that should be firing but aren't, specifically the alert formatters and senders, the problem could be identified. Automating the search for call sites using a script helped to flag functions that only appear at their definition, revealing the dead code that had gone unnoticed for months.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.