KovertKlaus v0.2.0-alpha shipped on October 1. The first real users are now creating Holiday Missions, building Wishlist Manifests, and inviting their Elf Agents.

On October 13 two things happened within a few hours: the first unprompted “this is actually sick” from a user, and the first user-reported bug. This post is about the bug, because what it revealed was more useful than the fix.


The Symptom

A user opened Account Preferences, edited their profile, and clicked save. They got this:

API route not found: /api/users/profile

The route existed, and it had worked in development. So why was it a 404?


The Diagnosis

The browser modal sent a PUT request. The production edge worker only had a handler for PATCH on that path, so a PUT fell through to the catch-all “route not found” response.

That explained the 404, but it was only the first layer. Once I read the handler line by line next to the client code, I found four more problems:

#ProblemEffect
1The client sent PUT, the server accepted only PATCHEvery save failed with a 404
2The client sent currentPassword, the server read oldPasswordPassword changes could never pass verification
3Most dossier fields (address line 2, delivery notes, sizes, favorites, allergies, preferred codename) were never written or readData the user entered was silently dropped
4Privacy toggles used one naming scheme in the UI and another in the databaseVisibility preferences never persisted
5The update response returned the entire user row, including the password hashSensitive data leaked to the client

Item 5 is the one that mattered most. A password hash is not a plaintext password, but it should never leave the server. Nobody reported it; it turned up only because a different bug made me read the whole handler.


The Fix

All five issues share one root cause: the client and server each had their own idea of the API contract, and nothing checked that the two agreed.

The fix moved that contract into a single, tested module:

  • One shared field allowlist. A new profile-update module defines which fields the profile endpoint accepts, maps each one to its database column, and sanitizes every value. Anything not on the list is ignored.
  • Both methods accepted. The route handles PUT and PATCH, so the client’s choice of method no longer matters.
  • A safe response shape. The update returns an explicit select of non-sensitive fields, never the raw database row.
  • Tests for the contract. Six new unit tests cover the allowlist, field mapping, and sanitization. The full suite passed 201 of 201 before the merge.

The Delivery Loop

This is the part I’m proudest of. The full path from report to production:

  1. Bug report from an alpha user
  2. Diagnosis and a fix/profile-update branch
  3. Tests and build pass locally
  4. Pull request merged into the development repository’s main branch
  5. Automated sync: a CI workflow opens a sync pull request in the production repository
  6. Production deploy on Cloudflare after the sync merges

It all happened in one afternoon. The automated sync step had been finished only the day before, so this was its first real run.


Lessons

  1. A 404 can hide a contract problem. The visible error was a routing miss; the real problem was five separate disagreements between client and server.
  2. Define a contract once and test it. When field names exist in two places, they will drift. Put them in one module and test it.
  3. Never return raw database rows. Select the response fields explicitly, even on “internal” endpoints.
  4. Fixing one bug is a reason to read the whole function. The worst issue here was found next to the reported one, not in it.
  5. Build the pipeline before you need it. The fix shipped the same day because the sync automation was already in place.

A Note for Alpha Users

If you filled in your Operative Dossier (sizes, favorites, delivery notes, and so on) before October 13, those details were not saved. Please take a minute to enter them again. Everything saves correctly now.

Thank you to everyone testing the alpha. Keep the reports coming.

Try it: kovertklaus.com · Source: GitHub