One hardcoded enum list broke a new feature across an entire production app
A software team added a seventh theme, 'birthday,' to a picture-book generator, updating types, forms, sitemaps, and content — but missed a hand-written Zod enum inside the API route that still listed only six themes. Every user request through the front-end returned a 400 error all day, while internal scripts and unit tests bypassed the route entirely, keeping the test suite green. Multiple copies of the same stale six-theme list were scattered across seed files, admin filters, SEO catalogs, and even a test file that defined its own 'valid' themes — meaning the test passed precisely because it never encountered the new value. The fix was to derive a single source-of-truth constant from the existing metadata map and import it everywhere, eliminating the possibility of the API gate drifting from the create form. A lint-style test was also added to flag any file containing three or more hardcoded theme literals in a row, enforcing the pattern going forward.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in