A calendar library returned the same answer for every year — and my tests agreed with it
I build a Korean saju (BaZi) service. The whole pitch is that the numbers are computed deterministically and only the prose is written by a model, so the calculation layer is the one part that is not allowed to be vaguely right. Two days ago I found out it had been wrong for five years of birthdays, and that my test suite had been cheerfully confirming it the entire time. What the function was…
This reporter built a Korean BaZi (saju) service, which computes numbers deterministically, with prose written by a model. However, the calculation layer was found to be incorrect for five years of birthdays, and the test suite had been confirming this error. The function was supposed to determine the year, month, and day pillars of a saju chart, which changed at solar terms (24 points where the sun reaches a fixed ecliptic longitude).
The year pillar turns at 입춘 (315°), which varies based on the time of birth. The reporter discovered this issue while testing against a calendar library that provided solar term instants. The library consistently returned the same answer for every year, while the independent astronomical computation provided eleven different results for the same date range.
The reporter's test suite, which relied on the library's output, had been passing all tests. The reporter devised a test to ensure that different years produce different solar term instants, revealing that the library ignored the year argument and returned the same value for all years. This type of bug, where a parameterized lookup function fails to read its input, can produce uniformly incorrect output, which is the most troublesome type of bug.
To prevent such bugs, the reporter recommends cross-checking dependencies against independent implementations, choosing probes that straddle the boundary being tested, and asserting variance on any parameterized functions.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.