Skip to main content
All editions

Beyond the Abstraction

Why Can't You Reproduce That Production Bug?

Bruno Valente e Costa · · 6 min read

There's a special kind of frustration reserved for bugs you can see but can't touch.

Production is broken. Users are complaining. The error logs are clear. You know exactly what's happening.

You just can't make it happen again.

You pull the code. You set up your environment. You follow the exact steps. And... nothing. It works perfectly. The bug that's actively breaking production refuses to show up on your machine.

This is the debugging experience that slowly erodes developer sanity.

The Reproduction Paradox

Here's the paradox: you need to reproduce a bug to fix it, but the bug only exists in conditions you can't reproduce.

Not "won't reproduce." Can't.

Your dev environment doesn't have the data conditions that trigger it. The scenario that breaks production doesn't exist in your database. The edge case is real, just not in any environment you can debug.

So you guess. You theorize. You stare at logs and stack traces and try to reason about what might be happening. You add logging statements and deploy them to staging, hoping to catch more information. You wait.

Meanwhile, the bug continues breaking things for actual users.

Why Bugs Disappear in Dev

I've watched this pattern dozens of times. The reasons bugs vanish in dev environments fall into predictable categories.

Volume disappearance. The bug only triggers when there are 10,000 records. Your dev database has 50. The code path that fails at scale never executes at test volumes.

Relationship disappearance. The bug involves a specific combination of data relationships, an order that references a discontinued product, a user with permissions from a merged department. Your test data has clean, logical relationships. Production has ten years of accumulated edge cases.

Timing disappearance. The bug appears when certain records were created before a schema change, or when data was migrated from a legacy system. Your dev database was created last month. It has no history.

Invalid data disappearance. This is the one that surprises people most. Production databases often contain data that shouldn't exist according to the platform rules!

Data That Shouldn't Exist

Over the years, we've found things in production databases that the platform documentation says are impossible.

Tenant IDs set to zero. Orphaned records with no parent. Foreign keys pointing to deleted entities. Required fields that are null. Enum values that don't match any defined option.

How does this happen?

Direct database access. On-premises deployments where DBAs have full database access. Someone ran a "quick fix" script years ago. The platform didn't validate it because it bypassed the platform.

Failed migrations. A migration script crashed halfway through. Some records were updated, others weren't. The rollback didn't fully restore everything.

Legacy imports. Data brought in from an older system that had different rules. The import tool didn't enforce current constraints.

Platform bugs. Sometimes the platform itself had issues that created invalid states. The bug was fixed, but the invalid data remains.

These situations create bugs that are nearly impossible to reproduce. The code is correct. The logic is sound. But it encounters data that no one anticipated because that data isn't supposed to exist.

The Three-Day Bug Fix

Here's a pattern we've all seen repeatedly.

Day one: Bug reported. Developer investigates. Can't reproduce locally. Adds logging. Deploys to staging.

Day two: Logs reviewed. Hypothesis formed. Fix attempted based on theory. Deployed. Doesn't work. Back to logs.

Day three: More detailed logging. More hypotheses. Finally, someone gets database access and discovers the actual data state. The bug becomes obvious. Fix takes 20 minutes.

Three days to fix a 20-minute bug. Not because the developer was slow. Because they couldn't see what they were debugging.

The Debugging Tool That Isn't a Debugger

There's a saying I've come to believe: The best debugging tool isn't a debugger. It's real data.

Breakpoints don't help if you can't trigger the condition. Stack traces don't help if the scenario doesn't exist in your environment. Logging doesn't help if you're logging the wrong thing because you can't observe the actual failure.

What helps is having the bug happen on your machine.

And for that, you need the data conditions that trigger it.

What Changes With Real Data

When dev environments contain production-representative data, including the messy parts, the edge cases, the historical artifacts, debugging transforms.

The bug that took three days to diagnose? It shows up locally. You can step through it. You can inspect the actual values. You can understand exactly why it's failing.

The invalid data scenario? It exists in your dev database, because it exists in production. You encounter it during development, not during a production fire.

The volume-dependent performance issue? It appears when you're writing the code, when you have time to optimize, not when users are timing out.

This isn't theoretical. I've watched teams go from "we can't reproduce production issues" to "we found it immediately", same developers, same skills, different data.

The Security Question

"But we can't put production data in dev environments, it contains sensitive information."

This is a valid concern. And it's not a blocker. But it deserves serious attention.

Production databases contain PII: customer names, email addresses, phone numbers, sometimes payment information, health data, or other sensitive details. Copying this directly to dev creates real compliance exposure. Under GDPR, that test database with customer records is still personal data, still subject to regulation, still a potential breach.

I've seen organizations where the dev database contains three-year-old customer data that nobody remembers copying. Where departed employees' data sits in test environments, never deleted despite deletion requests. Where developers have access to customer information they have no business reason to see.

The solution isn't to avoid production-representative data. It's to handle it properly.

Production data can be anonymized: personal information transformed into realistic but fake equivalents. Names become other names. Emails become generated emails. Addresses become plausible but fictional addresses. The anonymization happens before the data ever reaches the dev environment.

The data patterns remain. The volume remains. The edge cases remain. The invalid data states remain. What changes is the sensitive content, and the compliance risk disappears.

This requires proper tooling and process. It requires thinking about data security from the start, not as an afterthought. But it's a solved problem. The teams I work with who've made this shift don't sacrifice security for debuggability, and they sleep better knowing their test environments aren't hidden compliance risks.

A Diagnostic

If you're a platform lead or developer experiencing this frustration, here's a quick diagnostic:

Think about your last three production bugs that were hard to diagnose.

For each one, ask: Could I have reproduced this in dev if my dev database looked like production?

If the answer is yes even once, you have a data gap that's costing you time. Probably significant time.

The debugging skill isn't lacking. The debugging conditions are.

The Accumulation Effect

Here's what often gets missed: this isn't just about individual bugs.

It's about the pattern. The accumulation. Bug after bug that takes three days instead of three hours. Each one chipping away at confidence, velocity, and developer satisfaction.

Teams get used to it. "That's just how production bugs are." "We can never reproduce those." "You have to debug from logs." "It worked on my machine"

But it doesn't have to be that way. The gap can be closed.

Your Turn

What's your experience with production bugs that can't be reproduced?

Have you found techniques that work, ways to capture enough context to debug effectively without production data access?

Or have you made the shift to production-representative dev environments? If so, what changed?

I've spent years on this problem. I'm always curious how others approach it.

Bruno