Urgent.News

What's breaking now, across thousands of outlets.

Tech

The Counter That Counted a Call the Preflight Never Reached

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…

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.

Upon 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.

The 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.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

.NET 10 NU1015: Fix PackageReference Without Version Restore Failures

.NET 10 NU1015 turns a PackageReference without a version into a restore error. I like the stricter default because an unbounded direct dependency can quietly resolve the lowest package version.

  • .NET 10 NU1015 enforces version requirement for direct PackageReference entries
  • Versionless references now cause restore failures in .NET 10
  • Resolve by adding version or using Directory.Packages.props

Don't validate the output. Validate that you were allowed to generate it.

Introduction I run a site that collects overseas viewer comments about individual anime episodes, translates them, and publishes them. It updates automatically every day.

  • Check function compares claimed air date with observed date from MyAnimeList (MAL)
  • Five-day tolerance accounts for time zones and streaming delays
  • Early exit if any episode fails air date check to prevent false information generation

Enforcing a style rule with a linter that actually fails the build

Background I run a fleet of static sites that publish new content every day, mostly unattended. One of the house style rules is simple: no emoji anywhere in our own copy.

  • Linter enforces no emoji rule in static site publishing
  • Author solves linter failing build with emoji in certain situations
  • Linter includes features to track exclusions and unused allow-list entries

More from Sunday 23 August →