Lurker News
After a frantic scramble this morning, our billing team has finished patching a bug which erroneously was charging our monthly subscribers for an extra day.

All test suites are passing now, and SRE has scheduled a postmortem after the QA confirms the fix in 2028.

Comments (481) 159 threads

Earlier comments
masklinn#
Had a pair of tests break CI.

At least one of them was the test, code it was testing did its job fine but test could not cope with February 29th. Obviously the test is broken in two different ways: it fails on Feb 29 and more importantly tests the behaviour on $current-date so only tests edge cases on the day of.
Other I didn’t follow.

bun_terminator#
Yes, a few mildly bad things go wrong on a feb 29th. Everything that handles stuff a year from now for example. Pretty bad for a planning program. But our customers noticed and avoided that. Codebase is too ancient and brittle to even attempt to fix. Or at least boss doesn't want to invest time in it.
bauble1 reply#
I had a unit tests for a Java LocalDate that was being increased by one year. It checked whether the month and day were the same, and failed because the current day (29) didn't equal the year-hence one (28). I changed it to check that the difference between the days was less than two.
nathanwh1 reply#
Previously your unit test was broken one day every four ish years. Now it's broken every day :)
bspammer2 replies#
A unit test shouldn’t even be depending on the current date in the first place
dimaaan#
Right, fixed such test today
yen223#
This is a hard-earned lesson, but it's true.

Instead of doing

  def do_something_with_date():
      now = datetime.now()
      return now - timedelta(days=2)
you should do

  def do_something_with_date(now):
      return now - timedelta(days=2)
and explicitly pass in edge-case dates into the `now` param in your unit tests.

Alternatively, if you're using Python, use the freezegun library to fix the current time in tests: https://github.com/spulec/freezegun

acutesoftware1 reply#
Our ETL process is heavily monitored so we never miss a days data, but we got a surprising error "cant build aggregates - missing data, aborting MV refresh, data will be a day old". It was the year to date (YTD) calculation - no data for 29/2/2023 to compare to today.
bombcar2 replies#
This is why -365 days can be better than -1y.
OJFord#
Frankly unless you've considered it ahead of time and thought you'd handled it, IMO you want the error. What's the correct thing to do here? I don't think it's necessarily -365d, it might be, but if I was GP I'd be glad for the chance to consider it and decide what's correct - instead of it just blowing up or even worse silently going whichever way's wrong and undetected for a while.
jedberg#
Until tomorrow when your system is now off by a day for the next 365 days.

Load more comments