// lab log
The lab entry that was always today's news
A lab entry with no date didn't cause an error. It showed today's date and jumped to the top of the log. I changed the build so it fails instead.
2 min read
The bug
Lab log entries are sorted by the date written at the top of each one, newest first, and the two newest appear on the home page.
So what happens if you forget the date? In a test, there was no error. The entry built successfully, displayed today's date and went straight to the top of the log.
Why it happens
When a file has no date, Eleventy falls back to the file's creation time. That's a sensible default on a laptop, where the file really was created on that day. It's less sensible on a build server.
Cloud builds typically start from a fresh copy of the code, so the files are likely to be newly created each time. An undated entry could then be given a new date on every deploy and keep its place at the top of the log, pushing genuinely new entries down the home page.
The fix
There was no sensible date to guess, so the build now checks every entry. If one has no date, the build stops with an error that names the entry.
I tested it both ways: an entry with a date publishes, and removing the date fails the build with that message.
A related trap
The same review found a similar problem in my entry template. It carried a setting to keep it unpublished, and a copy that kept that setting would build cleanly but never appear on the site. No error, just a missing page.
That setting now applies based on where a file lives, so a file stops being a draft as soon as it moves out of the drafts area.
What I took away
Both bugs produced a successful build with the wrong result. For a small site I'm the only one checking, and a loud failure before deploy is much better than a quiet mistake on the live site.