Urgent.News

What's breaking now, across thousands of outlets.

Business

I fixed the limit check in a function nothing calls: green tests, dead code, live payment route

I'm Eric Gitangu. I work on the backend of a mobility/fintech platform. This one is about a limit check I fixed, tested and shipped, in a function the live payment route never calls. The setup Users top up a wallet through several payment rails: card, a few mobile-money rails, a web flow. Each location can set a minimum and a maximum top-up amount. If it sets none, a default range applies. Each…

In this report, I detail a limit check I identified, tested, and implemented in a function that was not called by the live payment route. The setup involves users topping up a wallet through various payment channels, each with its own minimum and maximum limits. A problem arose when a blank limit was treated as an empty value instead of "nothing set", causing the system to enforce an unattainable maximum limit.

The fix involved a resolver that only applied the default limit if the input was a positive number, otherwise falling back to the default. This fix was implemented across four payment routing files and included source checks to prevent the old code from reappearing. Another issue discovered was that the fix had been implemented in a function that was not called by the live route, meaning the new code would never be used in real-world scenarios.

To address this, the fix was moved to the appropriate place where the money is entered, allowing for earlier refusal of invalid payments. Tests were added to validate the new implementation, ensuring that the route refuses invalid payments before any further processing occurs. The report concludes with a summary of the changes and lessons learned, emphasizing the importance of testing through the actual route of the software and deleting any dead code to prevent confusion and future reimplementation of the same fix.

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 Business

More from Tuesday 17 November →