Ever have a bug that just annoys you that it slipped past you into production? You're kind of mad at yourself that it happened, but you're also frustrated at the weird combination of things that caused it?
I had one of those last week. On this project, we offer certain features in a wide variety of languages (over 20 at last count).
Historically, these have all been two-character ISO 639-1 language codes like en
or fr
.
Because of that, the field in the database storing the language was a CHAR(2)
field. How efficient!
Enter the bug: We got a request to add ISO 3166-2 locale-specific subdivisions like pt-BR
and pt-PT
.
You can probably guess where this is going. I forgot the field length was set so short in the database, so I didn't increase its size.
Even worse, all of our tests were still using two-character languages, so no tests failed.
And bad, bad Joel, I didn't manually test the feature. It was something so simple. We add languages all the time. I got complacent.
So I'm annoyed it happened, and I'm annoyed at myself for letting it happen, but what can I learn from this? I always like to learn and improve.
I came up with 3 things:
- I should definitely have taken the 30 seconds to manually test the new language. Even though it's simple, it's still simple to manually smoke test.
- Because I was introducing something new to the app (a longer language code), I should have updated a few tests to use the longer languages.
- This one I'm not sure of yet, but maybe it was unnecessary to limit that field to 2 characters in the first place? At a minimum, we could have set it to 10 or something. I'm torn on this one.
Anything else you can think of? I love hearing how others approach these situations too.
Here to help,
Joel
P.S. Want to get a little better at Laravel each day? Check out our free book, A Little Bit of Laravel, to get started.