Backend Engineer Discovers Tested Fintech Fix Was Hidden in Dead Code

Eric Gitangu · Software Engineering: An engineer found a tested fintech fix hidden in uncalled code.

Backend engineering reports from mobility and fintech platforms frequently highlight subtle integration oversights, but few illustrate the deceptive nature of isolated unit tests as clearly as a recent production post by developer Eric Gitangu. The account details a scenario where a critical wallet top-up limit check was successfully debugged, unit-tested, and shipped to production, only to reveal that the live payment routing logic never actually invoked the updated function.

The Blank Value Trap and Default Overrides

The operational setup of the platform allows users to fund wallets via multiple payment rails including cards, mobile-money integrations, and web workflows. Each operational location can configure custom minimum and maximum top-up boundaries, falling back to system defaults if no custom limits are specified. Historically, individual rails maintained separate copies of this bounds-checking logic, creating maintenance friction across the codebase.

Complications arose because administrative forms saved blank limit configurations as empty values rather than treating them as unconfigured parameters. Consequently, validation checks evaluated empty entries as active constraints that overrode default system limits. Locations saved with blank limits inadvertently enforced a maximum threshold of zero, rejecting legitimate top-up requests or triggering server errors during underlying arithmetic processing. To resolve this inconsistency, the engineering workflow introduced a unified bounds resolver designed to ensure that stored boundaries override defaults exclusively when represented as positive, finite numerical values, while also preventing inverted range configurations.

The Disconnect Between Unit Tests and Live Routing

While migrating several payment rails to the new centralized resolver, developers encountered a severe architectural blind spot concerning card top-up paths. The card validation module contained a specific top-up branch where the corrected limit check was implemented. Comprehensive unit tests driving this specific method directly produced passing results, confirming that blank limits retained defaults and out-of-range amounts were properly refused. Buoyed by these green test runs, the code was deployed during a morning production release.

However, runtime inspection revealed that live card top-up routes executed an entirely different validation function focused solely on verifying the presence of required fields. The modified validation branch was isolated and invoked exclusively by internal payout paths, a workflow that never evaluates card top-up criteria. Consequently, live card top-ups operated without any active limit enforcement before or after the deployment, allowing unconstrained transaction amounts to reach external card providers without triggering internal validation barriers.

Remediation, Integration Tests, and Additional Discoveries

Addressing the oversight required shifting the bounds resolution directly into the active validator invoked by public payment routes, positioning the validation check before any idempotency claims or external provider calls are made. This architectural change ensures that rejected transaction amounts incur no processing costs and leave no orphaned records behind. To prevent regressions, engineers implemented automated integration tests that drive real public routes inside child processes utilizing network request doubles.

During the remediation process, developers uncovered adjacent defects of a similar family. Another top-up route relied on data projections missing necessary currency and location fields, preventing its limit evaluation block from executing against real data. Additionally, a mobile rail eligibility check evaluated an undefined configuration key that caused blanket refusals for all transactions while that rail remained inactive. Both issues were corrected alongside the main deployment, which successfully reached staging and production environments without generating subsequent server errors.

Why Dead Code Passes Every Test You Write

This engineering episode underscores a fundamental vulnerability in software testing practices: a test that directly invokes an isolated method proves only that the method functions correctly in a vacuum, providing zero assurance about whether production execution paths actually invoke that code. In financial platforms and high-stakes backend systems, this gap between unit testing and route execution can mask severe functional omissions under a false sense of security. When developers write tests that bypass public routing layers, dead or disconnected code can easily pass every assertion asked of it because uncalled functions possess nothing to lose. The incident emphasizes that critical transactional paths require end-to-end integration testing that enters strictly through public routing entrypoints, accompanied by strict static analysis checks to guarantee that refactored resolution logic remains actively wired into production traffic rather than lingering in abandoned validation branches.

Key takeaways about why dead code passes tests and how integration testing prevents vulnerabilities in backend systems.

Editorial graphic and headline text by Signal Titans.

Source: I fixed the limit check in a function nothing calls: green tests, dead code, live payment route · I fixed the limit check in a function nothing calls: green tests, dead code, live payment route | Eric Gitangu

Share this article
FacebookThreadsLinkedInX

Leave a Reply

Your email address will not be published. Required fields are marked *