If you haven't already, first read the previous post about Encryption & Data Security. This one picks up where it left off: with the user Ben, locked out.

Legacy data

When we started hashing passwords, we changed the rules for how a password is stored. Every user who signs up from now on gets a bcrypt hash. But Ben and Brian signed up before the change. Their rows are still exactly the way the old code left them: the password as typed.

That's legacy data: rows created under rules the code no longer follows. Nothing is wrong with the rows themselves. They were correct when they were written. The code moved on, and they didn't move with it.

Every app that lives long enough has it. A user_id column added to posts after a thousand posts existed: those posts belong to nobody. A required phone number added after half your customers signed up without one. A price that used to be in dollars and is now in cents. Any change to the shape of your data has to answer one question: what happens to the rows that are already there?

We didn't answer it. We made a good change - storing passwords safely - and the result was two customers who can't log in.

Technical debt

Say we don't have time to fix it properly today. What would we do in the meantime? We could check the password both ways: if the stored value looks like a bcrypt hash, check it with bcrypt; otherwise, compare it as typed. Or we could check when the user signed up, and send everyone from before a certain date down an old path while everyone else takes the new one.

Both work. Both are extra code whose only job is to accommodate the change. That's technical debt: code (or data) that exists because of a shortcut, or a change we haven't finished dealing with, rather than because the product needs it.

The name is accurate. Like money you borrow, it buys you something now - the release goes out, Ben can log in today - and you pay interest on it for as long as you carry it. The interest is everything that gets harder:

  • Every engineer who touches the login now has to understand both paths, and why there are two.
  • Every new feature that touches passwords (a reset link, two-factor, a rule against "password" as a password) has to be built twice, or decide to ignore the old users.
  • Every path is a place for a bug, and the old path is the one nobody tests anymore.

And the interest compounds. Workarounds get built on top of workarounds. The longer debt lives, the more code depends on it, until it isn't a side path anymore but part of the foundation, and paying it off means a whole team stopping to plan how to change something everything else stands on.

Paying it off

Debt has to be paid off at some point: someone has to go back and make the change complete, so the extra code can go. For Ben and Brian, that could be:

  • Migrate them. The plain passwords are still in the table, so a one-time script can hash every old row and the workaround can be deleted. Nobody notices.
  • Force a reset. Email everyone from before the change a link to choose a new password.
  • Upgrade on login. An app moving off an old, weak hash can't run that script, because it doesn't have the passwords either. It checks the old way one last time when each user logs in, then saves the new hash. The workaround stays until the last old user has logged in, or until you decide they never will.

None of these is only an engineering choice. An engineer can tell you what each one costs and what can go wrong. But "do we email 10,000 customers and ask them to reset their password?" is a product question: what will customers think, who writes the email, what happens to the ones who never click. "Do we take the login offline for an hour to migrate?" is a product question too. So is the choice of what to do until the debt is paid - keep the workaround, lock the old users out, or tell them. Technical debt is a product decision and an engineering decision at the same time, and it goes best when the people making each half talk to each other.

Making time for it

Paying off debt doesn't move the product forward. No customer sees it, and the return is hard to point to, so it's always the easiest work to push to next sprint. That's how six months of "next sprint" happens.

What works better is small and regular:

  • Give it time on a schedule. Every three or four weeks, give an engineer a day or half a day to work on whatever debt is causing them the most pain.
  • Take turns. One engineer one cycle, another the next, so two people aren't rewriting the same foundation at once on branches that will conflict.
  • Ask the engineers. You don't need a search. Anyone who has worked in a codebase knows where the debt lives: the code they tiptoe around, the file they hope they won't have to open. They may already have told you.
  • Start with the code you touch most. The login, the payment form, whatever every request goes through. Debt in a corner nobody visits costs little. Debt on the busiest path costs every day.

If you're building on your own with an agent, the same habit applies: every week or so, ask your agent to look through the codebase for technical debt it can see - duplicated code, workarounds, paths that only exist for old data - and pick one thing to clean up. An agent adds code quickly, which means it adds debt quickly too.

Practice

If you want to pay this one off yourself, the Practice section at the end of the auth README (github.com/dsgn425-fall2026/auth) has it as an exercise: move Ben and Brian onto hashed passwords with a one-time script. You write the user story and the definition of done first. Deciding what "paid off" means is the hard part.

Next: how a user who has logged in stays logged in, with cookies.