{
  "id": 2873421,
  "title": "The Counter That Counted a Call the Preflight Never Reached",
  "url": "https://urgent.news/2026/08/23/the-counter-that-counted-a-call-the-preflight-never-reached",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-08-23T21:05:52.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/b_w_615d21106a7ac6f6b8cc4/the-counter-that-counted-a-call-the-preflight-never-reached-4c6i"
  },
  "original_language": "en",
  "account": "The bug fix story revolves around a Python component that conducts a preflight check and subsequently executes a synchronous operation callback if the check is successful. The purpose of a counter is to record whether the callback's invocation proceeded normally, crucial for diagnostics. However, the previous implementation incorrectly returned 1 in cases where a handled failure occurred. This discrepancy arose because the successful path was anticipated to invoke exactly one operation. If the preflight check failed, the operation was never entered, and the function still returned 1, contradicting the actual control flow.\n\nUpon investigation, the old behavior could be summarized as: if preflight succeeded and operation succeeded, return 1; otherwise, return 1 regardless of what happened. The core fix introduced a straightforward change: a handled failure directly returns 0, while the only way to return 1 is when the operation callback invocation completes normally. This change ensures that observed control flow, rather than expected control flow, guides the counter's behavior.\n\nThe regression assertion verifies that when the preflight function raises an exception before calling the operation, completed_calls returns 0. This assertion holds under various conditions, including under normal Python execution and with optimizations enabled. The counter's purpose is to measure returns from normal callback invocations, not remote side effects or deferred work. It's designed for synchronous application code in a single process, not a sandbox for potentially harmful callbacks. Ultimately, this bug fix ensures that a preflight failure won't falsely report a completed call.",
  "summary": "This is a submission for DEV's Summer Bug Smash: Clear the Lineup , powered by Sentry . Project Overview I was working on a small Python component that performs a preflight check and then, if the check succeeds, invokes one synchronous operation callback. A counter records whether that callback invocation returned normally. The counter is used for diagnostics, so it must follow the control flow…",
  "key_points": [
    "Bug fix alters Python component's preflight check behavior",
    "Counter now accurately records normal callback invocation",
    "Regression test confirms 0 return on preflight exception"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}