Urgent.News

What's breaking now, across thousands of outlets.

Tech

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.

Read the original at dev.to →

More in Tech

First Action After Compromise: Blind the Audit

✓ Human-authored analysis; AI used for formatting and proofreading. If you're an attacker who's just landed in an AWS account, the most expensive thing about your future is detection.

  • Attackers disable audit trail to evade detection
  • Command used: aws cloudtrail stop-logging
  • Blind window can last several days

What 'Revocable' Actually Means at the Contract Level

If you've ever called approve() on an ERC-20 token and then moved on with your life, you've already brushed up against the thing this post is about: an approval is not a setting inside some app, it's…

  • Revocation removes user authorization to spend tokens.
  • Revocation involves a transaction setting allowance to zero.
  • Verifying allowance on chain prevents stale-permissive issues.

Pull Requests and code review: how to make your code easy to review

I once approved a PR without reading it. Not because I was lazy — because the description was blank, the title was "fix", and the diff had six hundred lines across eleven files with no explanation of…

  • Clear PR title indicates action in imperative mood
  • Description answers why, what, and testing instructions
  • Break down large features into smaller, focused PRs

More from Tuesday 1 September →