Some defects do not come from a wrong calculation. They come from two correct calculations that use different assumptions.
I work on file interfaces between payroll software and external recipients, including exports to pension funds. One of these exports had a monthly reporting rule: changes count for the current period only up to a cut-off in the middle of the month. Later changes wait for the next period.
What went wrong
The export had two steps that both cared about dates.
- The first step decided which employees belonged in the file. It used the end of the reporting window.
- The second step calculated the effective date for each change. It used the mid-month cut-off.
Each step made sense when read alone. Together they created a gap. A person who joined after the cut-off passed the first filter, but the second step found no valid change. It then fell back to a default: the first day of the year.
The file looked normal. It had the right columns, a plausible date, and no technical error. Only someone who knew the case could see that the date was wrong.
A related case followed the same pattern. A salary change entered after the cut-off was exported with its new value, while the date still pointed to an earlier period.
The fix was mostly about ownership
I did not want to patch the fallback, because the fallback was only the symptom. The change I proposed moved the question "up to which date is a change reportable?" into one shared function. Both steps now ask that function instead of working it out on their own.
Three habits came out of this:
- Search for every caller before changing shared logic. A date rule often lives in more places than the first bug suggests.
- Be suspicious of quiet fallbacks. A default that produces plausible data is harder to notice than an error. If a fallback is needed, it should at least leave a visible warning.
- Keep a test that reproduces the original symptom. The test protocol for this fix has a case for an entry after the cut-off, so the defect has a place to show up if it returns.
I also wrote down what the fix does not cover, such as manual changes made directly on a record. A known limit in a document is much better than a surprise in a later month.
How I would carry this into AWS (learning notes)
I have not built this kind of export on AWS in production, so treat this as my current thinking while I learn.
If the same process ran as a workflow in AWS Step Functions, I would calculate the reference date once at the start and pass it through the execution input. No later state would read the clock on its own. A retry or a late run then works with the same date as the first attempt.
If Amazon EventBridge Scheduler started the workflow, I would set the time zone on the schedule explicitly, because a business date like "the middle of the month" belongs to a local calendar, not to UTC.
The technology changes, but the question stays the same: how many places in this system believe they know what today's cut-off is? The right answer is one.
Loading article