It sounds like you did everything right:
- You checked before the “three and a half years” point.
- The mezuzah was not in a vulnerable place, such as in direct sunlight or exposed to the rain. In such cases, you would have had to check it at least once a year or more, depending on the circumstances.
As such, not only can you not be faulted for this unfortunate discovery, but you will receive reward as well. Our Sages assure:
If a person plans to do a mitzvah but is prevented from completing due to circumstances beyond his control, Scripture credits him as if he had performed it.
Although there is no halachic requirement to check indoor mezuzahs yearly, some authorities record the meritorious custom of checking mezuzot every Elul.
 Kuntres HaMezuzah, citing Yosef Ometz 479 and Parashah Sedurah 70.
 Aruch HaShulchan Y.D. 291:1.
 Mishnah Berurah 39:26, in reference to tefillin.
 Berachot 6a, cited in Agur B’ohalecha 39:6.
 Kitzur Shulchan Aruch 128:3; See Mateh Efraim 581:10.