Y2K22 - The Mistake That Embarrasses Us
Published: 2022-01-13 14:43:35

*Is the year 2022. We keep programming in the 1950s*

> TL;DR: We need to follow one simple rule. Follow the [bijection](https://dev.to/mcsee/the-one-and-only-software-design-principle-3086).

The new year arrived with new errors on Microsoft Exchange.

It causes millions of emails worldwide to go undeliverable.

Many of them remain [stuck in email transport queues](https://techcommunity.microsoft.com/t5/exchange-team-blog/email-stuck-in-exchange-on-premises-transport-queues/ba-p/3049447).

Some queues are full and cause entire servers to crash.

# The problem

Y2K22 is familiar to engineers like me who worked in [Y2K Bug](https://en.wikipedia.org/wiki/Year_2000_problem).

[Someone](https://www.reddit.com/r/sysadmin/comments/rt91z6/exchange_2019_antimalware_bad_update/) abused an incorrect date representation by using something that is not a date.

Exchange's malware scanning engine stores signature dates using [32-bit integers](https://en.wikipedia.org/wiki/32-bit_computing).

Using integers to store dates is a clear bijection violation.

Also a primitive obsession and [premature optimization](https://dev.to/mcsee/code-smell-20-premature-optimization-4moe) code smell.

# The Chain of Responsibilities

Some developer decided (probably without a real benchmark) that storing dates as 32-bit integers was a smart move.

However, The largest possible number that can be stored in 32-bit is *2147483647*.

Things were fine for the 2021 dates because it was stamped as 211231XXXX (for 31st December) using YYMMDDhhmm format.

Yet another smell, Date and time are continuous and consecutive measures. 

So are integers, but not this absurd representation.

But the developer was not alone. 

The peer reviewer stated that it was a very good optimization.

Also, the QA team forgot to make basic boundaries testing using the [Zombies technique](https://dev.to/mcsee/how-i-survived-the-zombie-apocalypse-59gj).

# The error

[Happy new year](https://en.wikipedia.org/wiki/Year_2000_problem#Year_2022_problem). 

It is January 1st, 2022, according to this [bijection](https://dev.to/mcsee/the-one-and-only-software-design-principle-3086) we need to convert it to 2201010001. 

This is not possible when trying to format it to 32-bits.

The outcome is larger than the maximum number allowed.

This would cause timestamp validations on the server software to fail.

As a result, lots of emails are not being sent piling up on servers.

# The fix

Fixing this problem. ([It is not a bug](https://dev.to/mcsee/stop-calling-them-bugs-57gl)) is very difficult. 

Exchange is a product running on on-premises servers so it has to be patched manually in many cases.

The manual fix you can execute on your Powershell console is [easy](https://techcommunity.microsoft.com/t5/exchange-team-blog/email-stuck-in-exchange-on-premises-transport-queues/ba-p/3049447)

> Set the date on the signature file as 2112330001 (December 33rd, 2021)

Yes. it is no joke. 

That is the patch. 

Violate and abuse the bijection again creating representations of not real entities.

Using this exploit to set this invalid date should also raise an error according to [fail fast principle](https://dev.to/mcsee/fail-fast-48dm).

# Conclusions

If you want to develop serious software and be proud of it, just be loyal to the bijection.

If you create accurate models of your problems your software will always work as expected.

{% post https://dev.to/mcsee/the-one-and-only-software-design-principle-3086 %}