theboreddev.com

Menu
  • Home
  • Career
  • Code Habits
  • Debugging
  • Side Projects
  • Tooling
  • About Us
  • Contact Us
  • Disclaimer
Menu
How to upgrade a dependency safely.

Upgrade One Thing at a Time

Posted on July 8, 2026November 7, 2026 by Tomasz Wierzbicki

I remember sitting in my kitchen at 3:15 AM, staring at a terminal window while the blue light of my laptop felt like it was burning holes into my retinas. I had just bumped a minor version of a logging library, thinking it was a routine task, only to watch our entire payment gateway choke on a subtle change in how exceptions were serialized. Everyone talks about “automated dependency management” and “semantic versioning” as if they are magical shields, but if you want to know how to upgrade a dependency safely, you have to stop trusting the changelogs and start trusting your observability.

I’m not here to sell you on some complex, enterprise-grade orchestration tool or a new framework that promises to solve everything. I’ve spent too many years in the trenches of logistics and insurance to believe in silver bullets. Instead, I want to share the actual, unpolished workflow I use to ensure that a version bump doesn’t turn into a weekend-ruining incident. We’ll look at the trade-offs of canary deployments, how to write tests that actually catch breaking changes, and why your rollback strategy is more important than the upgrade itself.

Table of Contents

  • Why Semantic Versioning Best Practices Failed You
  • Managing Breaking Changes in Software Without the Panic
  • My personal checklist for not waking up the on-call engineer
  • The TL;DR for when you're too tired to read the whole post
  • The Long Game
  • Frequently Asked Questions

Why Semantic Versioning Best Practices Failed You

Why Semantic Versioning Best Practices Failed You

We’ve all been there: you see a patch release, check the changelog, and think, “It’s just a minor fix, it’ll be fine.” This is where the theory of semantic versioning best practices hits the brick wall of reality. The idea that a version number is a reliable contract is a nice thought, but in practice, it’s often just a suggestion. I’ve seen plenty of “minor” updates introduce subtle behavioral shifts—not outright crashes, but tiny changes in how an object is serialized or how a timeout is handled—that don’t trigger a single red flag in a standard build.

The problem is that SemVer assumes the maintainer is perfect and that their definition of a “breaking change” aligns with yours. It doesn’t. A library might maintain API compatibility while completely changing its internal concurrency model, which is enough to turn your high-throughput service into a bottleneck. Relying solely on the version number is a dangerous game; if you aren’t pairing your updates with rigorous automated dependency testing, you aren’t actually managing risk, you’re just gambling. I stopped trusting the numbers a few years ago after a “safe” patch update nearly wiped out a database connection pool in our production environment.

Managing Breaking Changes in Software Without the Panic

Managing Breaking Changes in Software Without the Panic

The reality is that even when a library follows the rules, a “minor” update can still blow up your service if it changes how an underlying resource is handled. I’ve spent far too many hours debugging a situation where a dependency update didn’t change the API signature, but it did change the way it handles connection pooling. To stop the panic, you have to stop treating updates like a single event and start treating them like a controlled experiment. This means moving away from the “bump and pray” method and toward automated dependency testing that actually exercises your critical paths, not just your unit tests.

If you want to sleep through the night, you need a predictable way to undo your mistakes. I don’t care how much you trust your tests; you need defined rollback strategies for updates baked into your deployment pipeline. For me, this means ensuring that our continuous integration deployment workflows allow us to revert to the previous container image in seconds, rather than minutes spent frantically trying to revert a commit and rebuild a broken artifact. It’s not about being perfect; it’s about making the cost of being wrong low enough that it doesn’t become a crisis.

My personal checklist for not waking up the on-call engineer

  • Read the actual changelog, not just the version number. I’ve seen “minor” updates that quietly deprecated a method our entire payment pipeline relies on. If the changelog is just a list of commit hashes, treat that dependency like a live grenade.
  • Run your smoke tests in a staging environment that actually mirrors production. There is a specific kind of pain that comes from realizing your local environment is too “clean” to catch the subtle race condition introduced by a new library version.
  • Use a lockfile and commit it. I learned this after a build server pulled a “compatible” version that was actually a broken release, and suddenly none of us could deploy anything. If you aren’t pinning your transitive dependencies, you aren’t in control.
  • Audit the blast radius before you merge. Ask yourself: “If this library fails, does the whole platform go down, or just one non-critical background job?” If the answer is the whole platform, you need a much more rigorous testing plan.
  • Prepare the rollback plan before you hit ‘merge’. I never start an upgrade without knowing exactly how to revert the change in under two minutes. If you have to spend twenty minutes debugging why the rollback failed, you’ve already lost the battle.

The TL;DR for when you're too tired to read the whole post

Stop trusting the version number alone; a “minor” update can still break your specific implementation, so run your integration suite every single time.

Build a safety net of automated tests before you even touch the `package.json` or `go.mod` file, otherwise you’re just gambling with your sleep schedule.

If a dependency is critical to your core business logic—like a payment gateway or a database driver—treat an upgrade like surgery, not a quick patch.

The Long Game

Managing dependency risk: The Long Game.

At the end of the day, upgrading a dependency isn’t about mastering a specific tool or finding the perfect CI/CD pipeline; it’s about managing risk through visibility. We’ve talked about why SemVer is often a lie, why you need to run those integration tests before the pager goes off, and how to handle the inevitable breaking changes without losing your mind. The goal isn’t to achieve a state of zero risk—that’s impossible—but to ensure that when things do go sideways, you aren’t staring at a black box wondering what changed. Treat every version bump as a small, controlled experiment rather than a leap of faith.

I’ve spent enough years cleaning up messes to know that the most dangerous thing in a codebase is a “set it and forget it” mentality. If you treat your dependencies like static infrastructure, they will eventually betray you. Instead, build a culture where updates are frequent, small, and boring. If an upgrade feels like a massive, terrifying event, you’re probably doing it too infrequently. Aim for the kind of stability where updates are just another Tuesday, not a high-stakes gamble. It won’t make the bugs disappear entirely, but it will certainly let you sleep a little better when the sun goes down.

Frequently Asked Questions

What do I do when a "minor" patch actually breaks my build and there's no clear way to roll back?

First, stop trying to “fix” the code. You’re in a panic, and that’s when you delete the wrong directory. If you can’t roll back the dependency version in your lockfile, you have to pin the last known working version explicitly. If the build is truly stuck, I’ve had to manually vendor the old source into a local directory just to get the CI green again. It’s ugly, but it stops the bleeding.

How much of my actual application logic should I be testing versus just relying on the library's own test suite?

I don’t care how many green checkmarks the library’s CI has. You aren’t testing their code; you’re testing your assumptions about it. I’ve seen “stable” dependencies fail because they didn’t account for the specific way we pass nulls or how our connection pool behaves under load. Test the integration points—the way your logic actually touches their API. If you don’t wrap their behavior in your own safety net, you’re just outsourcing your stability to a stranger.

Is it worth the overhead of pinning every single sub-dependency, or am I just creating a maintenance nightmare for myself?

I’ve tried both extremes. Pinning every single sub-dependency feels like trying to hold back the ocean with a spoon—you’ll spend your entire weekend fixing trivial security patches. But leaving everything loose is just asking for a non-deterministic build that breaks when you least expect it. My middle ground? Pin your top-level dependencies and use a lockfile. Let the lockfile do the heavy lifting of pinning the tree, but don’t manually manage the leaves.

At what point does the risk of staying on an old, potentially insecure version outweigh the effort of a safe upgrade?

It’s a balancing act, but I usually look at the CVE severity versus the “blast radius” of the upgrade. If it’s a critical remote code execution vulnerability in a library that touches our public edge, you upgrade immediately—even if it’s messy. If it’s a minor security patch in an internal tool behind three layers of VPC, I’ll wait until the next scheduled maintenance window. Don’t fix a theoretical risk by introducing a guaranteed outage.

Learning how to move from junior to mid level.

The Jump Is About Judgement, Not Syntax

Posted on July 8, 2026November 7, 2026 by Tomasz Wierzbicki

I spent most of my early twenties thinking that if I just memorized enough documentation or mastered the latest React hooks, I’d magically level up. I was wrong. Most of the “career roadmaps” you see on LinkedIn are just collections of buzzwords designed to sell you a bootcamp or a subscription. They tell you to learn more languages, but they never tell you that knowing how to move from junior to mid level has almost nothing to do with how many syntax patterns you can recite. Real growth isn’t about adding more tools to your belt; it’s about understanding why the tools fail when the traffic spikes and the database locks up.

I’m not here to give you a checklist of frameworks to study over the weekend. Instead, I want to talk about the stuff that actually matters: ownership, debugging under pressure, and the ability to see a system as a series of trade-offs rather than a collection of perfect code. I’ll share what I’ve learned from the production incidents that kept me awake at night and the mistakes that actually taught me something. This is about moving from someone who completes tasks to someone who solves problems.

Table of Contents

  • Mastering Independent Problem Solving When Everything Breaks
  • Increasing Technical Proficiency Through Post Mortem Analysis
  • Beyond the Syntax: Five Habits That Actually Signal You're Ready
  • The Mid-Level Shift in Practice
  • The Long Ride Ahead
  • Frequently Asked Questions

Mastering Independent Problem Solving When Everything Breaks

Mastering Independent Problem Solving When Everything Breaks

The biggest tell that someone is ready to move past the junior phase isn’t how many languages they know, but how they act when the dashboard turns red. A junior sees a failing service and immediately pings a senior on Slack with a screenshot of the error. They aren’t wrong to do it, but they are treating the symptom rather than the disease. If you want to focus on independent problem solving, you need to change your default response. Before you tap anyone on the shoulder, I want you to show me the trail of breadcrumbs you’ve already followed: the logs you parsed, the recent deployments you checked, and the specific hypothesis you’ve already ruled out.

This isn’t about pretending you have all the answers—that’s a fast track to making a massive mistake in production. It’s about showing that you can navigate the fog. When I was at the insurance firm, I realized that demonstrating leadership qualities often just meant being the person who brought a structured investigation to the table rather than just a problem. Instead of asking “What do I do?”, start asking “I’ve ruled out the database connection pool and the recent config change; could it be a memory leak in the new worker process?” That shift in communication is what actually signals you’re ready for the next level.

Increasing Technical Proficiency Through Post Mortem Analysis

Increasing Technical Proficiency Through Post Mortem Analysis

Most people treat a post-mortem like a legal deposition—a way to assign blame and move on. If that’s your approach, you’re missing the most efficient engine for increasing technical proficiency available to you. When a service goes down, don’t just patch the leak and close the ticket. I’ve learned that the real value lies in the “why” behind the “what.” Instead of just fixing the bug, I start digging into the systemic reasons it was allowed to reach production in the first place. Was it a lack of telemetry? A misunderstood concurrency model? A silent failure in a downstream dependency?

This isn’t about being a perfectionist; it’s about building a mental library of failure modes. When you start documenting these patterns—not just for the team, but for your own sanity—you stop being a person who reacts to incidents and start being someone who anticipates them. This shift is a core part of professional skill development that separates the juniors from the mids. A junior fixes the symptom so they can go back to their task; a mid-level engineer investigates the root cause so the symptom never returns. It’s a slower way to work in the moment, but it’s the only way to stop solving the same problem twice.

Beyond the Syntax: Five Habits That Actually Signal You're Ready

  • Stop asking for the answer and start presenting the options. When you hit a wall, don’t just ping a senior saying “it’s broken.” Show them what you’ve already tried, what the logs said, and the two ways you think we could fix it—even if you’re wrong about both. I’d much rather spend five minutes reviewing your logic than twenty minutes explaining the basics.
  • Learn to read the code you didn’t write. Juniors tend to treat existing repositories like black boxes; they write new code on top of it and hope for the best. Mid-level engineers spend a significant amount of time tracing execution paths through legacy modules to understand the side effects. If you can’t explain how a change in Service A affects the database schema in Service B, you aren’t ready to own the feature.
  • Start thinking in trade-offs, not “best practices.” There is no such thing as a perfect architecture, only a series of compromises. When you suggest a tool or a pattern, don’t just tell me why it’s good; tell me why it might be bad. If you can tell me why we shouldn’t use a specific library because of its latency overhead or maintenance cost, you’re thinking like an engineer, not a student.
  • Own your mistakes before the monitoring system does. We all break things—I certainly have. The difference between a junior and a mid-level dev is the speed of the feedback loop. Don’t wait for a Slack alert to tell you the error rate is spiking. If you see a weird metric in your dashboard, investigate it immediately. Being the person who finds the bug before the customer does builds a level of trust that no certification can buy.
  • Write documentation for your future, tired self. I have a rule: if I have to solve a problem twice, I’ve failed. Moving to mid-level means you stop just “fixing” things and start building systems that prevent the same mistake from happening again. This means writing clear READMEs, documenting why a specific weird workaround exists, and making sure the next person doesn’t have to go through the same 2 AM headache you just did.

The Mid-Level Shift in Practice

Stop treating bugs like annoyances and start treating them like documentation; the real skill isn’t fixing the code, it’s understanding the systemic reason why the error was even possible.

Shift your focus from “how do I make this work?” to “what happens when this fails?”; a junior builds for the happy path, but a mid-level engineer builds for the inevitable 2 AM outage.

Ownership means more than just completing tickets; it means being the person who leaves the codebase better—and better documented—than they found it, so the next person doesn’t have to suffer through the same mystery.

The Long Ride Ahead

The Long Ride Ahead: Career Growth.

At the end of the day, moving from junior to mid-level isn’t about how many new languages you can add to your LinkedIn profile. It’s about the shift from asking “how do I write this?” to “what happens when this fails?” It’s about the discipline of doing your own post-mortems, the patience to solve problems without a tutorial, and the habit of documenting your mistakes so they don’t become the team’s recurring nightmares. If you can start looking at a production incident as a data point rather than a personal failure, you’re already halfway there.

Don’t rush the process. I spent years cycling through different stacks and side projects before I actually felt like I knew what I was doing. Software engineering is a marathon, not a sprint through a new framework’s documentation. Focus on building a reliable mental model of how systems actually behave under pressure, and the title change will eventually take care of itself. Just keep writing things down, keep breaking things in staging, and try to be the person who leaves the codebase slightly better than they found it.

Frequently Asked Questions

How do I know when I've actually solved a problem versus just applying a band-aid that'll break again in six months?

You know it’s a band-aid when you’re relieved just because the alert stopped screaming, but you can’t explain why it stopped. If your fix is “restarting the service” or “increasing the memory limit” without finding the leak, you haven’t solved anything; you’ve just bought yourself time. A real solution feels a bit more uncomfortable—it usually involves changing a process, adding a constraint, or rewriting the logic that allowed the failure to be possible in the first place.

Is there a way to start practicing post-mortems if my current team doesn't actually do formal ones?

You don’t need a formal meeting or a Jira template to do this. If your team doesn’t do them, start doing “personal post-mortems.” When you push a fix for a bug or recover a service, don’t just close the ticket and move on. Open a private note. Write down: what happened, why the monitoring didn’t catch it sooner, and what single change would have prevented the headache. It’s just documentation for your future self.

How do I balance the need to move faster with the need to document things properly so I don't repeat my own mistakes?

I’ve spent too many hours re-solving the same bug because I thought I was “too busy” to document it. Here is the reality: documentation isn’t a separate task; it’s part of the task. If you don’t document the “why” behind a weird configuration change, you aren’t moving faster—you’re just building technical debt that you’ll have to pay back with interest at 2 AM. Write the README as you code, not as an afterthought.

At what point should I stop asking for permission and start just proposing the solution, even if I'm not 100% sure it's right?

Stop asking for permission once you can frame your uncertainty as a trade-off. If you come to me saying, “I think we should use a message queue here because it handles spikes better, even though it adds some latency,” you’ve already won. You aren’t asking me to do your job; you’re asking me to peer-review your reasoning. That transition—from “What should I do?” to “Here is the problem and my proposed trade-off”—is exactly what mid-level engineers do.

How to record and replay HTTP traffic.

Record the Call Once, Replay It Forever

Posted on July 6, 2026 by Tomasz Wierzbicki

I once spent an entire weekend trying to replicate a race condition in our staging environment, only to realize that the “synthetic” load tests we were running were nothing like the chaotic, malformed garbage hitting our actual production endpoints. We had all these expensive observability suites promising insights, but none of them actually showed me how to record and replay http traffic in a way that captured the actual nuance of a failing request. It turns out, simulating a user is easy; simulating the specific, weirdly-timed sequence of headers that actually breaks your state machine is a much different beast.

I’m not going to sell you on some shiny, enterprise-grade service that requires a six-month implementation plan just to catch a few edge cases. Instead, I want to talk about the pragmatic, sometimes messy ways to actually capture real-world payloads and feed them back into your local environment. I’ll walk through what I’ve learned from the failed attempts and the production outages that taught me the hard way, focusing on tools and patterns that actually work when you’re staring at a broken dashboard at 2 AM.

Table of Contents

  • Capturing Network Packets Before the Evidence Vanishes
  • Why Proxy Server Recording Beats Guessing in the Dark
  • Five things I learned the hard way about traffic capture
  • What I’ve learned from the wreckage
  • The Hard Truth About Reproducing Reality
  • Frequently Asked Questions

Capturing Network Packets Before the Evidence Vanishes

Capturing Network Packets Before the Evidence Vanishes

The problem with most debugging sessions is that by the time you’ve actually realized something is wrong, the specific sequence of events that caused the failure has already evaporated. You’re left staring at logs that tell you what happened, but they rarely tell you the how of the actual payload. When I was at the insurance firm, we once lost a whole afternoon because we couldn’t recreate a specific race condition caused by a weirdly formatted header. We weren’t just looking for logs; we needed capturing network packets in a way that actually preserved the state of the conversation between services.

If you want to move toward deterministic network testing, you have to stop relying on manual reproduction. I’ve found that setting up a proxy server recording layer is usually the most pragmatic way to go. Instead of trying to build complex mocks for every edge case, you just sit a transparent proxy in the middle of the traffic flow. It catches the raw, messy reality of the wire—the timeouts, the unexpected 503s, and the malformed JSON—before they get sanitized by your application’s error handling. It’s much easier to debug a recorded stream of reality than it is to guess what a service might have sent you three hours ago.

Why Proxy Server Recording Beats Guessing in the Dark

Why Proxy Server Recording Beats Guessing in the Dark

I’ve spent way too many hours trying to reproduce a race condition by manually tweaking JSON payloads in Postman, hoping I’d eventually hit the same edge case that crashed the service last Tuesday. It’s a guessing game, and a losing one at that. When you rely on manual reproduction, you aren’t actually testing the system; you’re just performing a high-stress version of charades. Using proxy server recording changes the math entirely because it moves you away from “I think the request looked like this” to “I know exactly what the bytes looked like.”

The real value shows up when you move from chaos to deterministic network testing. Instead of praying that your staging environment behaves like production, you can use the recorded traces to feed your local setup. This is where you stop treating the network as a black box and start treating it as a predictable input. If you can feed your service the exact same sequence of headers and payloads that caused the spike in latency, you aren’t just guessing anymore—you’re actually debugging. It turns a frantic search for a needle in a haystack into a controlled experiment where you can finally see the needle.

Five things I learned the hard way about traffic capture

  • Sanitize your payloads before they hit the disk. I once spent an entire afternoon trying to scrub PII from a recorded trace because I realized too late that our staging environment was accidentally replaying real customer credit card numbers. If you don’t automate the masking, you’re just building a security vulnerability by another name.
  • Don’t ignore the headers. It’s easy to focus on the JSON body, but I’ve seen entire services fail because a specific `X-Forwarded-For` or `Content-Type` header was missing in the replay. The body is the message, but the headers are the context that actually makes the request work.
  • Watch your clock skew. When you’re replaying traffic into a system that relies on timestamps for idempotency or TTLs, you’ll find that the replay fails immediately if you aren’t careful. You either need to strip those timestamps or ensure your replay tool can simulate a “current” time context.
  • Mind the side effects. Replaying traffic against a live database is a great way to delete your production data or double-charge a user. I’ve learned to always wrap my replay sessions in a way that either targets a dedicated sandbox or uses a mock layer that can handle the inevitable “write” operations.
  • Capture the errors, not just the 200 OKs. If you only record successful requests, you’re building a library of a perfect world that doesn’t exist. You need to capture the 503s and the timeouts too; otherwise, you’ll never be able to test how your system actually recovers when the network starts acting up.

What I’ve learned from the wreckage

Don’t rely on logs alone; they tell you what the application thought happened, but a recorded traffic trace tells you what actually happened on the wire.

If you can’t replay a specific production failure in your local environment, you aren’t actually debugging—you’re just guessing and hoping for the best.

The cost of setting up a proxy to capture traffic is high upfront, but it’s significantly lower than the cost of another 3 AM incident where the root cause is a single, unrepeatable malformed request.

The Hard Truth About Reproducing Reality

The Hard Truth About Reproducing Reality.

At the end of the day, you have to choose your poison. You can try to sniff packets at the network layer and deal with the headache of decrypting TLS, or you can bake recording into your proxy layer and accept the slight latency trade-off. I’ve learned the hard way that guessing what a client sent is a losing game. Whether you’re using a dedicated service mesh or just a well-configured Envoy instance, the goal is the same: stop relying on your memory of the incident and start relying on the actual bytes that hit your wire. If you can’t replay the exact sequence of headers and payloads that caused the crash, you haven’t actually solved the problem; you’ve just patched a symptom.

I don’t expect anyone to implement a perfect traffic mirroring setup overnight. It’s heavy, it’s complex, and it requires discipline to manage the storage costs of all those captures. But I do suggest you start small. Pick one critical service—the one that keeps you awake on a Saturday—and figure out how to capture its input. Because one of these days, the system is going to do something completely unexpected, and instead of staring at a blank terminal in a panic, you’ll have the replayable evidence you need to actually fix the root cause and finally go back to sleep.

Frequently Asked Questions

How do I handle sensitive stuff like auth tokens or PII so I'm not accidentally leaking customer data into my local dev environment?

The last thing I want is to be the reason a customer’s session token ends up in a plaintext log file on my laptop. If you’re replaying traffic, you need a scrubbing layer. I usually bake a transformation step into my proxy setup—something that identifies headers like `Authorization` or fields like `email` and replaces them with deterministic hashes or dummy values. It’s a bit more setup upfront, but it beats the alternative.

What happens when the API schema changes halfway through a recorded session—does the whole replay just fall apart?

Yeah, it falls apart. Hard. I’ve been there: you replay a month’s worth of traffic against a new deployment, only to watch the error rates spike because a field that used to be a string is now an object. If your recorded payloads don’t match the current schema, the parser chokes and the replay is useless. You can’t just record blindly; you need a way to version your traces or, better yet, a way to transform the old data on the fly.

Is there a way to simulate high-latency or flaky connections during the replay, or am I stuck testing against perfect local network conditions?

If you only test against a perfect local loopback, you’re basically lying to yourself. I’ve seen plenty of “passed” CI pipelines melt the moment they hit a real-world mobile network. You can use something like `tc` (traffic control) on Linux to inject artificial latency or packet loss, or just use a proxy like Toxiproxy. It’s a bit of a chore to set up, but it’s better than being surprised by a timeout in production.

How much overhead am I actually adding to the system if I decide to run a transparent proxy in a production-like staging environment?

It’s a valid concern. If you’re running a transparent proxy in a staging environment that actually mirrors production load, you’re looking at a latency hit—usually a few milliseconds per hop—and some CPU overhead for the packet inspection. It’s not zero. But in my experience, the “overhead” of a slightly slower staging environment is a bargain compared to the overhead of a production outage because you couldn’t reproduce the edge case. I’d rather take the latency hit now.

How to avoid storing data you do not need.

The Safest Data Is the Data You Never Kept

Posted on July 3, 2026 by Tomasz Wierzbicki

I remember sitting in a dim home office at 3:14 AM, staring at a dashboard while a database migration choked on a table that shouldn’t have even existed. We weren’t even using half the columns in that schema, but they were there because someone, somewhere, thought “we might need this later.” That’s the trap. Most people treat storage like it’s infinite and free, but I’ve learned that the cost isn’t just the monthly AWS bill; it’s the cognitive load and the sheer friction of maintaining a graveyard of useless information. If you want to learn how to avoid storing data you do not need, you have to stop thinking like an archivist and start thinking like a plumber.

I’m not here to sell you on some high-level architectural framework or a shiny new governance tool that requires three months of meetings to implement. Instead, I want to share the practical, somewhat painful lessons I’ve picked up from years of cleaning up production messes. I’ll show you how to build intentionality into your data lifecycle from the very first commit, so you aren’t left debugging a bloated system in the middle of the night.

Table of Contents

  • Why Bloated Databases Are Your Biggest Production Liability
  • Reducing Data Breach Impact Before the Crisis Hits
  • Five ways I stopped treating our database like a digital junk drawer
  • The TL;DR for the Next Person
  • The Long View on Data Hygiene
  • Frequently Asked Questions

Why Bloated Databases Are Your Biggest Production Liability

Why Bloated Databases Are Your Biggest Production Liability

I’ve seen it happen more than once: a database that was manageable during the MVP stage starts to grow like a weed once you hit scale. Suddenly, your backups take twice as long, your index rebuilds are a nightmare, and your queries that used to take milliseconds are crawling because the engine is wading through petabytes of historical junk. It isn’t just a performance issue; it’s a massive liability. When you keep everything “just in case,” you aren’t being prepared—you’re just increasing the surface area for disaster.

The real headache hits when something actually goes wrong. If a malicious actor gains access to your environment, the damage isn’t just proportional to what they can steal right now, but to everything you’ve ever collected. By failing to implement strict data retention policies, you are essentially handing them a treasure trove of stale user info that should have been purged years ago. I’ve learned that reducing data breach impact is often more effective when you simply don’t have the data to lose in the first place. It’s much easier to explain to a stakeholder why a specific table was empty than to explain why five years of unencrypted, unnecessary logs were leaked.

Reducing Data Breach Impact Before the Crisis Hits

Reducing Data Breach Impact Before the Crisis Hits

I used to think that having more data was a safety net, but after seeing a breach at my old logistics startup, I realized it’s actually a liability. When the attackers got in, they didn’t just take what they needed; they took every scrap of historical user data we had “just in case.” If we had followed basic GDPR data minimisation principles and actually purged those old records, the blast radius would have been significantly smaller. You can’t lose what you don’t have.

The reality is that reducing data breach impact isn’t just about better firewalls or more complex encryption; it’s about aggressive hygiene. I’ve found that the most effective way to handle this is to move away from manual cleanup and toward automated data deletion workflows. If you wait for a human to remember to run a cleanup script, you’ve already lost. I prefer setting up TTL (Time To Live) values at the database level or using scheduled jobs that treat data like milk—if it’s past its expiration date, it gets tossed immediately. It’s a bit of extra engineering work upfront, but it beats explaining a massive data leak to the legal team at 4 AM.

Five ways I stopped treating our database like a digital junk drawer

  • Stop using “catch-all” JSON blobs for everything. I used to think storing unstructured data was a shortcut to speed, but it’s actually just a way to hide technical debt. If you don’t know exactly what’s in a field, you can’t prune it, and eventually, you’re paying to store garbage you can’t even query.
  • Set an expiration date on your data at the moment of creation. If a log entry or a session object doesn’t have a TTL (Time To Live) defined in its schema, it’s basically a permanent resident. I’ve learned that if you don’t explicitly decide when data dies, it will live forever and eventually crash your indexing service.
  • Audit your telemetry with a cynical eye. We often log entire request payloads “just in case” we need to debug something later. Most of that data is useless 99% of the time, but it’s still eating up IOPS and storage. If you aren’t actively using a specific field for a business requirement or a critical alert, stop writing it to the disk.
  • Implement a “deletion-first” mindset during schema design. When I’m sketching out a new service, I try to ask “what happens if we lose this field in six months?” if the answer is “nothing much,” then we probably shouldn’t be collecting it in the first place. It’s much easier to not store data than it is to try and surgically remove it from a multi-terabyte table later.
  • Watch your staging and dev environments. It’s easy to let production-sized datasets leak into lower environments for “realistic testing.” This doesn’t just increase your cloud bill; it creates a massive security footprint of data that shouldn’t even be there. Use synthetic data or scrubbed subsets instead of just cloning the whole production dump.

The TL;DR for the Next Person

If you aren’t actively using a piece of data to drive a business process or a feature, it shouldn’t be in your primary database; treat storage like a high-interest loan, not a free resource.

Implement automated TTLs (Time To Live) or expiration policies early in the development cycle—relying on a manual “cleanup script” written by a developer who will eventually leave the company is a recipe for a disk-full outage.

Audit your logging levels in production; a “debug” flag left on in a high-traffic environment is just a slow-motion way of filling up your expensive SSDs with useless noise.

The Long View on Data Hygiene

The Long View on Data Hygiene concept.

At the end of the day, avoiding data bloat isn’t about following some abstract compliance checklist or being a purist about storage costs. It’s about reducing your blast radius. Every extra column in a table and every legacy JSON blob sitting in a cold storage bucket is just another potential liability waiting for a misconfigured permission or a rogue script to turn it into a crisis. If you implement strict TTLs, automate your cleanup scripts, and—most importantly—start asking “do we actually need this?” during the design phase, you aren’t just saving money on your AWS bill. You are building a system that is fundamentally easier to defend when things inevitably go sideways.

I’ve spent enough nights staring at flickering monitors to know that complexity is the enemy of sleep. You can try to build the most sophisticated monitoring stack in the world, but it’s much more effective to simply not have the junk in your system to begin with. Treat your data like a heavy backpack on a long cycling trip; if you carry everything “just in case,” you’re going to burn out long before you reach the summit. Aim for a lean, intentional architecture. It might feel like extra work now, but your future self—the one getting paged at 3 AM—will definitely thank you for it.

Frequently Asked Questions

How do I actually identify which data is "dead weight" without accidentally breaking a downstream service that relies on a field I thought was unused?

I’ve spent too many nights staring at a broken pipeline because I deleted a “useless” column that a legacy reporting service was secretly scraping. Don’t just delete; observe. I use database audit logs and query telemetry to see who is actually touching what. If your infra doesn’t track field-level access, you’re flying blind. My rule of thumb: if you can’t prove a field hasn’t been queried in ninety days, treat it like a live wire.

At what point does the engineering cost of building a robust data retention policy outweigh the actual risk of keeping the data?

It’s a sliding scale, but the math changes once you hit the “compliance or death” threshold. If you’re just cleaning up old user preferences, it’s a low-priority chore. But if you’re sitting on PII that triggers GDPR or PCI-DSS audits, the cost of building an automated deletion pipeline is almost always cheaper than the legal fees or the fine. If you can’t automate the cleanup, you’re just accumulating technical debt that eventually pays out in a crisis.

How do you handle the "just in case" mentality from product managers who want to keep everything for future analytics?

I’ve been in these meetings. The “just in case” argument is usually a proxy for “I don’t know what we need yet.” My approach is to stop arguing about the data and start talking about the cost of the mistake. I tell them: “We can store this, but it’s going in a cold S3 bucket, not our production DB.” If they want it in the live system, they need to define the query that justifies the storage overhead.

What's the safest way to prune massive production tables without causing a locking nightmare or a massive spike in replication lag?

Don’t try to run a single `DELETE` statement with a massive `WHERE` clause. You’ll lock the table, spike your replication lag, and probably get paged at 3 AM.

How to debug a permission error message.

Denied, and the Message Will Not Say Why

Posted on July 2, 2026 by Tomasz Wierzbicki

I was halfway through a lukewarm coffee at 3:14 AM when the pager went off, signaling that our service account had suddenly lost access to the S3 bucket. It wasn’t a code change or a deployment; it was a silent, creeping drift in an IAM policy that nobody had touched in six months. Most tutorials will try to teach you a complex hierarchy of cloud security abstractions, but they rarely tell you the truth about how to debug a permission error when the logs are lying to you. You don’t need a certification; you need to know which specific layer of the stack is actually swallowing the error message and leaving you in the dark.

I’m not going to give you a lecture on the theoretical principles of Least Privilege—you can find that in any vendor’s documentation. Instead, I want to walk through the actual, messy process of tracing a denial from the application level down to the kernel or the cloud provider’s API. I’ll show you the specific commands I use to verify identity and the common blind spots where permissions usually hide. My goal is to give you a repeatable mental model so that the next time this happens, you aren’t staring at a screen in confusion, but moving straight to the fix.

Table of Contents

  • Why Resolving Denied Access Errors Is Never About the Code
  • Tracing the Broken Link Between Process and Path
  • Five things I learned from chasing ghosts in the filesystem
  • What I’ve learned from the trenches
  • The post-mortem mindset
  • Frequently Asked Questions

Why Resolving Denied Access Errors Is Never About the Code

Why Resolving Denied Access Errors Is Never About the Code

When you get that “Permission Denied” error, the instinct is to dive into your application logic. You start questioning your middleware, your service account’s identity, or whether your code is even trying to touch the right path. I’ve wasted hours doing exactly that, only to realize the code was perfectly fine and was simply being told “no” by the operating system. Resolving denied access errors is rarely a logic problem; it is almost always a mismatch between your application’s assumptions and the reality of the environment.

The actual culprit is usually buried in the layers of the OS that we tend to treat as magic. It’s the subtle interplay of the user group permission hierarchy or a stray entry in the file system access control lists that you forgot about when you last updated the deployment script. I’ve seen entire production rollouts stall because someone assumed a directory was world-readable, when in reality, the service was running under a restricted UID that had no business touching that specific mount point.

You have to stop looking at the syntax of your language and start troubleshooting Linux file permissions as a separate, fundamental layer of the stack. It’s not about your Python or Go code; it’s about whether the process actually has the right to exist in that space.

Tracing the Broken Link Between Process and Path

Tracing the Broken Link Between Process and Path.

Once you’ve accepted that the code itself is likely fine, you have to start looking at the gap between the process and the disk. When a service fails with “Permission Denied,” it’s rarely because the application logic is broken; it’s because the OS has decided the process is a stranger. I usually start by identifying exactly who the process thinks it is. I’ll run `ps aux` or check the container metadata to find the UID and GID. It sounds trivial, but I’ve lost entire afternoons because a service was running as `www-data` while the directory it needed was owned by `root`.

From there, it’s a matter of troubleshooting linux file permissions by walking the path from the root down to the actual file. You can’t just look at the target file; you have to check every parent directory in the chain. If a single directory in that path lacks the execute bit for your user, the whole thing falls apart. I don’t bother guessing; I use `namei -l /path/to/the/problem` to see exactly where the chain breaks. It’s a much faster way of mapping out the user group permission hierarchy than manually checking every single level with `ls -ld`. Once you find the broken link, you’ll know if you need to fix the ownership or if you’ve just fundamentally misunderstood your deployment’s security context.

Five things I learned from chasing ghosts in the filesystem

  • Stop looking at your code and start looking at the user. I’ve wasted hours debugging a perfectly fine logic block only to realize the service was running as `nobody` instead of `www-data`. Run `whoami` inside the actual execution environment, not just your local terminal.
  • The “Effective UID” trap is real. Just because you can `ls` a directory doesn’t mean your application can. If you’re using containers, remember that the user inside the pod might not map to the owner of the volume on the host. Check the actual numeric UID, not just the name.
  • Beware of the “Parental Lockdown.” You can have 777 permissions on a file, but if the parent directory is set to `700` and owned by `root`, your process is still hitting a brick wall. Permissions are a chain; if one link is broken, the whole thing fails.
  • Use `strace` to stop guessing. When the error message is a useless “Permission Denied,” stop staring at the logs and start watching the syscalls. `strace -e trace=file ./your_app` will show you the exact path and the exact moment the kernel says “no.”
  • Audit your ACLs and SELinux/AppArmor profiles. I once spent a whole afternoon fighting a permission error that looked like a standard filesystem issue, only to find out a security module was silently blocking the syscall. If the bits look right but it still fails, the OS is likely playing gatekeeper.

What I’ve learned from the trenches

Stop looking at your application logic first; permission errors are almost always a mismatch between the environment and the process, not a bug in your syntax.

Always verify the identity of the actual running user with `whoami` or equivalent, because assuming your local dev permissions carry over to a containerized production environment is a recipe for a 2 a.m. outage.

Document the specific path and ownership requirements in your README, because the next person (which might be you in six months) shouldn’t have to play detective with `ls -la` just to get the service to start.

The post-mortem mindset

Debugging layers with the post-mortem mindset.

At the end of the day, debugging a permission error isn’t a test of your coding ability; it’s a test of your ability to map out the invisible layers between the code you wrote and the OS that actually runs it. We’ve looked at how the culprit is rarely the logic itself, but rather a disconnect between the effective user and the file system, or a subtle mismatch in how a process inherits its environment. If you can trace the path from the process ID to the specific syscall that failed, you stop guessing and start knowing. It’s about moving from “why is this broken?” to “which layer of the stack is lying to me?”

I’ve spent more hours than I care to admit chasing these ghosts, and the frustration is real. But there is a specific kind of satisfaction that comes from finally seeing that `chmod` or `chown` command work, or realizing a container mount was misconfigured. My advice is to treat every one of these headaches as a documented lesson rather than just a chore to be finished. Write down the specific path and the specific user that caused the friction. If you do that, you aren’t just fixing a bug; you are building a mental map that will make the next 2 a.m. incident much, much quieter.

Frequently Asked Questions

What happens when the permissions look perfect on the file, but the service still claims it's denied?

This is where the real headache starts. You check `ls -l`, see `777` or at least the right owner, and still get a “Permission Denied.” Usually, it’s because you’re looking at the file, but the OS is looking at the path. If a parent directory in the chain is missing the `+x` bit, the service can’t “traverse” into the folder, regardless of what the file itself says. Or, more likely lately, it’s SELinux or AppArmor silently blocking the syscall.

How do I track down which specific user or service account is actually running the process when everything is wrapped in containers?

The container makes everything feel anonymous, which is a lie. When I’m staring at a `Permission Denied` in a pod, I stop looking at the YAML and start looking at the process itself. I’ll exec into the running container and run `id`. It’s the only way to be sure. If the container is running as `nobody` but your volume expects `1001`, you’re fighting a ghost. Don’t guess the UID; verify it.

At what point do I stop debugging the OS and start looking at the cloud provider's IAM policies?

You stop debugging the OS the moment `ls -l` and `id` tell you everything you need to know, but the application still claims it can’t see the file. If the local permissions look perfect and the process is running as the correct user, stop banging your head against `/etc/passwd`. At that point, the wall isn’t in your Linux kernel; it’s in the cloud provider’s IAM layer. Move up the stack.

How can I automate a check to catch these permission mismatches during a deployment instead of discovering them at 2 AM?

The easiest way is to stop trusting your local machine. I started adding a “pre-flight” step to our CI/CD pipeline that runs a containerized version of our deployment script. It uses the exact same non-root user defined in the production Dockerfile to attempt a `stat` or a dummy write on the critical directories. If the containerized user can’t touch the paths, the build fails immediately. It’s not elegant, but it catches the mismatch before the pager goes off.

Learning how to ask for a promotion.

Make the Case Before the Cycle Starts

Posted on June 30, 2026November 7, 2026 by Tomasz Wierzbicki

Most “career coaching” articles make asking for more money sound like a delicate diplomatic negotiation or a choreographed dance of corporate buzzwords. They tell you to “align your personal brand with company values,” which is just a fancy way of saying perform for your manager. I’ve spent fifteen years in the trenches of production environments, and I can tell you that nobody cares about your personal brand when the database is locking up at 3:00 AM. If you want to know how to ask for a promotion, stop looking for a script and start looking at your actual impact. You don’t win a new title by being polite; you win it by proving that the scope of your responsibility has already outgrown your current pay grade.

I’m not here to give you a motivational speech or a list of platitudes you can find on LinkedIn. Instead, I want to share the messy, unpolished reality of what actually moves the needle in a technical organization. I’ll show you how to build a paper trail of evidence that is impossible to ignore, and how to frame your value in terms that even a non-technical stakeholder can understand. No fluff, no evangelism—just the same logic I use to debug a failing deployment.

Table of Contents

  • Workplace Achievement Tracking Building Your Case in Real Time
  • Demonstrating Professional Value Before the System Breaks
  • Five things I learned while waiting for my manager to notice
  • The TL;DR for your next review
  • The Final Commit
  • Frequently Asked Questions

Workplace Achievement Tracking Building Your Case in Real Time

Workplace Achievement Tracking Building Your Case in Real Time

I learned this the hard way during my time at the insurance firm. I spent six months refactoring a legacy payment gateway that reduced latency by 40%, but when performance review season rolled around, I couldn’t remember a single specific metric or the exact date the deployment went live. I sat there like a junior dev during my first sprint planning, trying to explain “impact” without any data to back it up. Now, I treat workplace achievement tracking like I treat my logs: if it isn’t recorded, it basically didn’t happen.

Don’t wait until the week before your meeting to start digging through Jira tickets or old Slack threads. I keep a private, running document—mostly just a messy markdown file—where I jot down every significant incident I resolved or every piece of technical debt I cleared. It’s not about bragging; it’s about demonstrating professional value through hard evidence. When you finally sit down to discuss your trajectory, you aren’t asking for a favor based on “vibes” or how hard you’ve been working; you’re presenting a ledger of facts. This makes the actual conversation less about emotion and more about a logical business case for your next level.

Demonstrating Professional Value Before the System Breaks

Demonstrating Professional Value Before the System Breaks

The problem with most people’s approach to career advancement strategies is that they treat the promotion like a deployment that only happens once a year. You wait for the scheduled performance review, hope the logs are clean, and then act surprised when the “merge request” for your new title gets rejected due to lack of evidence. In reality, you shouldn’t be waiting for a formal meeting to start demonstrating professional value; you should be doing it every time you prevent a regression or optimize a slow query.

I’ve learned that if you only show up when things are broken, your manager will only associate you with the chaos. To change that perception, you need to highlight the silent wins—the stuff that didn’t break because you implemented a better testing suite or refactored that legacy module that everyone else was afraid to touch. This isn’t about bragging; it’s about providing visibility into the stability you’re providing. If you can show that you aren’t just fixing bugs, but are actively reducing the technical debt that causes those bugs in the first place, you’ve already won half the battle. It turns the conversation from “I’ve been here a year” to “I am fundamentally changing how this system operates.”

Five things I learned while waiting for my manager to notice

  • Stop treating your promotion like a surprise exam. If you walk into a review expecting a reward for “doing your job,” you’ve already lost. You need to be discussing the delta between your current role and the next one months before the paperwork actually moves. It’s about making the transition feel like an inevitability rather than a request.
  • Collect the logs, not just the highlights. When I was at the insurance firm, I realized that saying “I’m a hard worker” means nothing to a director. Saying “I reduced the latency on the settlement service by 200ms, which saved us three hours of manual reconciliation per week” is something they can actually put in a budget request.
  • Find the “unowned” problems and fix them. Every platform has that one messy subsystem that everyone avoids because it’s undocumented and brittle. If you become the person who can navigate that chaos without needing a hand-hold, you aren’t just a senior engineer anymore; you’re a force multiplier. That’s what a promotion is actually for.
  • Learn to speak the language of the business, even if it’s boring. I used to think that as long as my code was clean, I was winning. But if you can explain how your refactor prevented a potential outage that would have cost the company $50k in transaction fees, you’re suddenly speaking the language of the people who sign the checks.
  • Don’t mistake “busy” for “impactful.” You can spend forty hours a week fighting fires, but if those fires are caused by poor architecture you could have addressed, you’re just maintaining the status quo. High-level roles are about preventing the fire, not just being the best person at holding the extinguisher.

The TL;DR for your next review

Stop treating your career like a black box; if you aren’t logging your wins and the complexity of the fires you’ve extinguished, you’re essentially asking your manager to guess your value.

A promotion isn’t a reward for time served, it’s a recognition that you are already operating at the next level—so make sure your documentation proves you’ve moved past just fixing bugs to preventing them.

Don’t wait for the annual performance review to reveal your impact; by the time that meeting rolls around, the evidence of your growth should already be common knowledge in the codebase and the sprint reviews.

The Final Commit

Data proving The Final Commit.

At the end of the day, getting a promotion isn’t about winning a debate or mastering the art of corporate persuasion. It’s about the data. If you’ve been doing the work—tracking your wins in real-time, documenting the fires you prevented, and proving you can handle the complexity of the next level—then the conversation becomes a simple matter of aligning your title with your actual impact. You aren’t asking for a favor; you are presenting a logical conclusion based on the evidence you’ve spent months or years compiling. If the evidence is there and the answer is still no, you haven’t failed; you’ve just identified a system that is no longer compatible with your growth.

I’ve spent enough time in production environments to know that you can’t fix a broken architecture by just shouting at it. The same applies to your career. Don’t treat your professional development like a black box that you just hope will eventually output a better salary. Take ownership of the documentation, build your case with the same rigor you use for a critical post-mortem, and stop waiting for permission to be recognized for the value you already provide. Whether that means staying to fix the system or moving to a new one, make sure you are the one driving the deployment of your own career.

Frequently Asked Questions

What do I do if my manager acknowledges my impact but says there is "no budget" for a title change or a raise?

When they say “no budget,” they’re usually telling the truth, but they’re also closing the door. Don’t fight the budget battle; fight the timing battle. If the cash isn’t there today, ask for a written commitment: “I understand. If we hit X revenue target or Y headcount, can we revisit this in six months?” Also, pivot to non-monetary equity. Ask for a title change now—it costs them nothing but builds your resume—or more PTO. Get it in writing.

How do I handle the conversation if my performance reviews have been mediocre in the past, but my actual output has significantly increased lately?

Don’t try to argue that your past reviews were “wrong.” That’s a losing battle that just makes you look defensive. Instead, treat your recent output like a new deployment. Acknowledge the delta: “My previous reviews reflected a different phase of my work, but the telemetry from the last six months shows a different story.” Show them the logs—the tickets closed, the incidents averted, the actual impact. You aren’t asking for a favor; you’re presenting new data.

Is it worth asking for a promotion if the company is currently going through a hiring freeze or a restructuring?

It depends on what you’re actually asking for. If you’re looking for a budget increase during a freeze, you’re fighting a losing battle against a spreadsheet. But if you’re asking for the title change now, you’re essentially pre-loading your value for when the freeze lifts. I’ve seen it work: lock in the seniority and the formal recognition while the company is reorganizing. It makes the eventual salary adjustment much harder for them to ignore later.

How much "extra" work should I actually be doing before I feel justified in making the ask?

Don’t fall into the trap of thinking you need to do two jobs to get one promotion. That’s how you end up burnt out and still underpaid. You aren’t looking for “more” work; you’re looking for “higher-leverage” work. If you’re just clearing more tickets, you’re just a faster engine. If you’re fixing the architectural flaw that causes those tickets in the first place, you’re operating at the next level. That’s the gap you bridge.

How to add authentication without pain.

Do Not Write Your Own Password Reset

Posted on June 28, 2026 by Tomasz Wierzbicki

I once spent an entire weekend at a logistics startup trying to integrate a “state-of-the-art” identity provider that promised seamless scaling but delivered nothing but undocumented edge cases and broken session redirects. I was sitting in a cold office, staring at a terminal that refused to acknowledge a valid JWT, wondering why everyone makes this so difficult. Most tutorials treat security like a magic spell you just cast over your code, but if you want to learn how to add authentication without pain, you have to stop looking at the shiny marketing slides and start looking at the actual state transitions in your database.

I’m not here to sell you on a specific vendor or a trendy new library that will be deprecated by next Tuesday. Instead, I want to walk through the boring, reliable patterns I’ve learned from years of seeing production environments crumble because someone thought they could “roll their own” crypto or skip the basics. I’ll show you how to build a layer that is defensive by default, so you can actually sleep through the night instead of debugging session expirations at 2 AM.

Table of Contents

  • The High Cost of Ignoring Third Party Auth Providers
  • Reducing Authentication Complexity Before Production Breaks
  • Five rules to keep your auth layer from becoming a liability
  • The Bottom Line
  • The Long View on Auth
  • Frequently Asked Questions

The High Cost of Ignoring Third Party Auth Providers

The High Cost of Ignoring Third Party Auth Providers

I learned this the hard way at that logistics startup. We thought we were being clever by building our own custom identity layer. We had our own tables, our own hashing logic, and our own session management. It felt like “real” engineering at the time. But then came the inevitable: a security patch was released for a dependency we used for token signing, and suddenly, we weren’t just fixing a bug; we were auditing our entire database to see if we’d been compromised. When you try to build it yourself, you aren’t just writing code; you are taking on the permanent, unpaid job of implementing identity management for the life of the product.

The hidden cost isn’t just the initial dev time; it’s the cognitive load. Every time a new requirement comes in—like adding Multi-Factor Authentication or supporting Apple ID—you have to pause your actual feature work to weave that into your custom spaghetti. By opting for third-party auth providers, you aren’t being “lazy” or “outsourcing the hard stuff.” You are simply deciding that your time is better spent on the business logic that actually makes the company money, rather than reinventing the wheel and praying you didn’t leave a backdoor open in your session handling.

Reducing Authentication Complexity Before Production Breaks

Reducing Authentication Complexity Before Production Breaks.

The mistake I see most often isn’t a lack of effort, but an excess of it. I’ve seen teams spend months building a custom identity layer, treating it like a core product feature, only to realize they’ve accidentally built a massive security liability. When you are reducing authentication complexity, the goal isn’t to write more code; it’s to write less. Every line of code you write to handle a password reset or a session refresh is a line of code that can fail while you’re halfway through a long ride or asleep.

Instead of reinventing the wheel, I prefer to lean on established standards. If you can keep your implementation focused on OAuth and OpenID Connect simplified, you move the heavy lifting to entities whose entire existence depends on not breaking. This doesn’t mean you stop being responsible; it means you stop being responsible for things that aren’t your primary business problem. You want to spend your engineering hours on your actual product, not on managing user sessions securely or worrying if your hashing algorithm is still considered “industry standard” this week. Keep the surface area small, delegate the complexity, and you’ll find the system is much easier to reason about when things actually go wrong.

Five rules to keep your auth layer from becoming a liability

  • Outsource the heavy lifting. I’ve seen enough “bespoke” credential storage systems fail to know that unless you are building a security company, you shouldn’t be handling raw passwords. Use a provider that lets you offload the risk of a database leak.
  • Treat your session logic like a production incident waiting to happen. If your session invalidation logic is “eventually consistent,” you’re going to spend your weekend dealing with users who can’t log out or, worse, users who can’t log back in after a minor deployment.
  • Write the failure modes first. Before you write a single line of integration code, ask yourself: “What happens to the user experience when the identity provider returns a 503?” If your answer is “the whole app crashes,” you haven’t finished the feature.
  • Keep your user schema decoupled from your auth provider. I once worked on a migration where we tried to map every single provider attribute directly to our core user table. When the provider changed their payload format, our database migration became a nightmare. Keep a thin abstraction layer between them.
  • Audit your scopes like you audit your spend. It’s tempting to just request `full_access` to everything during development because it’s easier, but that’s how you end up with a massive blast radius. Be stingy with permissions from day one; it’s much harder to claw them back later.

The Bottom Line

Don’t build your own identity provider unless your actual business is identity; the engineering hours you’ll spend fixing edge cases in password resets and MFA are hours you’re stealing from your actual product.

Complexity is a debt that compounds at 2 AM; every custom piece of logic you add to your auth flow is just another potential point of failure that you’ll eventually have to debug while exhausted.

Prioritize “boring” and standardized over “custom” and “clever”—in production, a boring solution that works is infinitely more valuable than a sophisticated one that requires a manual to operate.

The Long View on Auth

The Long View on Auth: managing risk.

At the end of the day, adding authentication isn’t about picking the “coolest” library or building the most complex custom handshake. It’s about managing risk. We’ve talked about why outsourcing the heavy lifting to a proven provider saves you from a weekend of emergency patching, and why keeping your internal logic simple is the only way to stay sane when a production incident inevitably occurs. If you try to reinvent the wheel, you aren’t just building a feature; you are volunteering to be on call for every edge case, security vulnerability, and protocol change that comes your way. My goal isn’t to make you a security expert, but to help you avoid building a house of cards that collapses the moment you try to scale.

I’ve learned the hard way that the best code is often the code you didn’t have to write. Every hour you spend fighting with a custom implementation is an hour you aren’t spending on the actual product that people are paying for. Don’t let the allure of “total control” trick you into a maintenance nightmare. Aim for a setup that is boring, predictable, and—most importantly—invisible during your sleep cycle. Build it so that when things go wrong, you can actually find the root cause instead of staring at a thousand lines of bespoke crypto logic. Keep it simple, keep it external, and go get some sleep.

Frequently Asked Questions

At what point does a third-party provider become more of a liability than a help, especially when we're talking about vendor lock-in?

It becomes a liability the moment you can’t imagine your system functioning without their specific API response structure. If migrating to a different provider means rewriting your entire user service and database schema, you aren’t using a tool; you’re hosting a hostage situation. I’ve seen teams get paralyzed by a vendor’s price hike or a sudden outage because they didn’t abstract the identity layer. Use the provider for the heavy lifting, but keep your core logic provider-agnostic.

How do I handle the transition from a simple social login setup to something more robust like MFA without rewriting my entire user schema?

The trick is to stop treating “authentication” as a single column in your database. I used to try and cram everything into a `user` table, which is a recipe for a migration nightmare later. Instead, treat authentication as a separate, extensible entity. Link your user to an `auth_methods` table. This way, when you need to add TOTP or WebAuthn, you’re just adding rows to a new table rather than performing surgery on your core user schema.

When should I actually bite the bullet and build a custom identity service instead of just layering more middleware on top of an existing provider?

You bite the bullet when the provider becomes a bottleneck for your core business logic, not just a nuisance. If you’re spending more time fighting their API quirks or paying “convenience taxes” that scale faster than your revenue, it’s time. Usually, this happens when you need deep, non-standard identity workflows—like complex multi-tenant hierarchies or specialized hardware tokens—that a generic provider simply wasn’t built to handle. Build it when the “off-the-shelf” solution starts feeling like a cage.

How do we test these authentication flows in our CI/CD pipeline without accidentally hitting production rate limits or creating a mess of mock users?

I once spent a whole afternoon cleaning up a test suite that had accidentally hammered our production OAuth provider, nearly triggering a lockout. Don’t do that. The trick is to use a local identity provider—something like Keycloak or even a simple Dockerized mock server—for your CI pipeline. It gives you predictable tokens without the latency or the rate-limit anxiety. If you must use the real provider, use a dedicated “sandbox” project with its own credentials.

How to debug a file descriptor limit.

Too Many Open Files Means a Leak

Posted on June 27, 2026 by Tomasz Wierzbicki

I remember sitting in a darkened apartment in 2016, staring at a terminal window while my coffee went cold, watching a service slowly suffocate. Everything looked fine on the dashboard—CPU was low, memory was stable—but the application was throwing “connection refused” errors like it was being shot. I spent two hours chasing a ghost in the network layer before I realized the truth: we were hitting a hard ceiling on our open handles. Learning how to debug a file descriptor limit isn’t something you find in a glossy, high-level tutorial; it’s something you learn when your pager goes off and the standard metrics tell you absolutely nothing about why your sockets are dying.

I’m not going to waste your time with a lecture on what a file descriptor is or why Linux uses them. You probably already know that. Instead, I want to show you the actual commands I use to find the leak, how to distinguish between a legitimate traffic spike and a leaky connection pool, and how to fix it so you aren’t staring at your screen at 2 AM. This is just a record of what actually works when the system starts hitting the wall.

Table of Contents

  • Why Troubleshooting Too Many Open Files Error Matters
  • Identifying Resource Leaks in Applications Before They Strike
  • Five ways I stop chasing ghosts in the logs
  • What I’ve learned from the trenches
  • Avoiding the Next 2 AM Wake-up Call
  • Frequently Asked Questions

Why Troubleshooting Too Many Open Files Error Matters

Why Troubleshooting Too Many Open Files Error Matters

It’s easy to treat a “Too many open files” error as a simple configuration tweak—just bump the limit and move on. But in my experience, that’s usually just masking a deeper rot. If you’re just increasing system open files limit every time a service hits a ceiling, you aren’t fixing the problem; you’re just giving a leaking bucket more room to hold water. Eventually, the ceiling moves, and the bucket still leaks.

The real danger is that these errors are rarely isolated. When a process hits its limit, it doesn’t just stop accepting new work; it often enters a zombie-like state where it’s technically “running” but functionally dead. I’ve seen entire microservice clusters cascade into failure because one service started identifying resource leaks in applications too late. By the time the monitoring alerts went off, the exhaustion had already cascaded through the network, making the root cause look like a massive spike in traffic rather than what it actually was: a single, poorly managed connection pool.

Ultimately, troubleshooting this matters because it forces you to look at how your software actually interacts with the OS. It’s about moving past the symptoms and understanding the lifecycle of your sockets and file handles. If you don’t get this right, you’re just waiting for the next 2 AM page to go off.

Identifying Resource Leaks in Applications Before They Strike

Identifying Resource Leaks in Applications Before They Strike

The problem with most “preventative” strategies is that they are reactive by design. You don’t realize you have a leak until the service starts throwing errors, but by then, the damage is already done. In my experience, the most effective way to avoid a middle-of-the-night outage is to stop looking at your application logs and start looking at the OS-level telemetry. I’ve learned that monitoring socket connections usage is a much more reliable early warning system than waiting for a 500 error to pop up in your dashboard. If you see a slow, linear climb in open descriptors that never quite returns to its baseline after a traffic dip, you aren’t looking at a spike; you’re looking at a leak.

Once you see that trend, you have to get surgical. I usually jump straight to the `lsof` command for process monitoring to see exactly what those descriptors are doing. It’s one thing to know you’re hitting the limit; it’s another to realize that 90% of your handles are stuck in a `CLOSE_WAIT` state because some junior dev forgot to close a client connection in a `finally` block. Identifying resource leaks in applications shouldn’t be a guessing game involving trial and error; it’s about mapping the file descriptors back to the specific code paths that are failing to clean up after themselves.

Five ways I stop chasing ghosts in the logs

  • Stop guessing and use `lsof -p [PID]`. I used to waste time checking network configs when the real culprit was just a rogue process holding onto thousands of stale log files. `lsof` tells you exactly what the file is, where it lives, and whether it’s a socket or a regular file.
  • Watch the `FD` column in `/proc/[PID]/fd`. If you see a massive list of files pointing to the same path or a specific library, you aren’t looking at “heavy load”—you’re looking at a leak. If that number keeps climbing linearly while your traffic stays flat, you’ve found your smoking gun.
  • Check your connection pool settings, not just your OS limits. I once spent a whole night bumping `ulimit -n` only to realize the application was just creating a new database connection for every single incoming request instead of reusing them. Increasing the limit just delayed the inevitable crash.
  • Use `netstat` or `ss` to differentiate between file handles and network sockets. In Linux, everything is a file. If your FD count is spiking, you need to know if you’re actually running out of disk handles or if your TCP connections are stuck in `CLOSE_WAIT` because the other end isn’t playing nice.
  • Audit your third-party client libraries. It’s rarely your own code that leaks; it’s usually the HTTP client or the cloud SDK you imported. If you aren’t explicitly calling `.close()` on a response body or a client instance, you’re essentially leaving the tap running until the system drowns.

What I’ve learned from the trenches

Don’t just bump the `ulimit`. Increasing the limit is a temporary bandage that often just delays the inevitable crash; you need to find the actual leak, otherwise you’re just building a bigger dam for a river that’s still flooding.

Monitoring is your only real defense. If you aren’t tracking the trend of open file descriptors over time in your dashboard, you aren’t going to see the slow climb toward the ceiling until the service is already dead.

Always check your third-party libraries. I’ve lost count of how many times the “leak” wasn’t in my code, but in a database driver or a logging utility that wasn’t properly closing its connections or file handles.

Avoiding the Next 2 AM Wake-up Call

Avoiding the Next 2 AM Wake-up Call.

At the end of the day, debugging a file descriptor crisis isn’t about memorizing every `lsof` flag; it’s about building a mental model of how your application actually handles resources. We’ve looked at how to track down the specific process hogging the handles, how to audit your connection pools, and why simply bumping the `ulimit` is usually just masking a leak rather than fixing it. If you can identify whether the culprit is a runaway log rotation, a database driver that isn’t closing sockets, or a misconfigured sidecar, you’ve already won half the battle. Don’t just patch the limit; find the leak and close it for good.

I’ve spent enough nights staring at terminal screens to know that these incidents feel personal when they happen. But if you treat every “Too many open files” error as a free lesson in how your system actually behaves under pressure, you stop being a victim of your infrastructure. My goal isn’t for you to become a Linux kernel expert, but to reach a point where you can look at a stack trace and predict the failure before the pager goes off. Write down what you found, automate the check, and hopefully, you’ll get to sleep through the night.

Frequently Asked Questions

How do I tell the difference between a legitimate spike in traffic and a slow, creeping resource leak?

The easiest way to tell is to look at the slope of the graph. A traffic spike is a mountain: it goes up fast, stays high, and then drops back down when the load subsides. A leak is a staircase or a slow ramp. If your file descriptor count keeps climbing even during the quietest hours of the night, you aren’t looking at a traffic problem; you’re looking at a leak that’s slowly drowning your process.

If I find the process leaking descriptors, how do I actually trace it back to the specific line of code or unclosed socket?

Once you’ve identified the PID, don’t just guess. I usually start with `lsof -p ` to see exactly what’s open. If it’s a mess of sockets, I use `strace -p -e trace=open,socket,close` to watch the system calls in real-time. If you see a pattern of `socket()` calls without a corresponding `close()`, you’ve found your leak. It’s tedious, but it beats hunting through thousands of lines of code blindly.

Is it safer to just bump the `ulimit` in the OS, or am I just delaying the inevitable crash?

Bumping the `ulimit` is like putting a larger bucket under a leaking pipe. It buys you time, but the water is still coming. If you have a genuine leak—say, a database connection pool that isn’t closing sockets—increasing the limit just delays the inevitable crash and makes the eventual failure harder to debug because the symptoms are masked. Increase it if you’re scaling for legitimate load, but if the number keeps climbing linearly, find the leak.

How do I monitor this in real-time so I'm not finding out about it from a PagerDuty alert at 2 AM?

I learned the hard way that waiting for the alert means you’ve already lost. If you’re using Prometheus, don’t just track the process-level limit; you need to export the actual count of open file descriptors via node_exporter. I set up a simple rate-of-change alert. I don’t care if we have 1,000 files open, but if that number is climbing linearly every ten minutes without plateauing, I want to know before the kernel starts killing connections.

How to keep dependencies under control.

Every Dependency Is Code You Did Not Review

Posted on June 26, 2026November 7, 2026 by Tomasz Wierzbicki

I remember sitting in my kitchen at 3:14 AM, staring at a terminal window while my coffee went cold, trying to figure out why a minor patch in a logging library had somehow nuked our entire payment gateway. It wasn’t a complex architectural failure; it was just a transitive dependency that had decided to change its behavior overnight. Most people will try to sell you expensive enterprise scanning tools or complex governance frameworks as the solution, but they miss the point. If you want to actually learn how to keep dependencies under control, you need to stop looking at high-level security dashboards and start looking at your lockfiles and your build pipeline.

I’m not here to lecture you on the theoretical merits of semantic versioning or which linting tool is the most trendy this week. Instead, I want to share the boring, practical stuff I’ve learned from years of cleaning up production messes. I’ll walk you through the specific, slightly manual habits that actually work—like pinning versions, auditing your tree before a deploy, and knowing exactly why a piece of code is in your repo. This isn’t about achieving perfection; it’s about making sure the next time something breaks, it’s a predictable problem rather than a midnight disaster.

Table of Contents

  • The Hidden Chaos of Transitive Dependency Management
  • How Third Party Libraries Become Your Biggest Liability
  • My survival guide for not letting a `npm install` ruin my weekend
  • What I’ve Learned from the Post-Mortems
  • The Cost of Doing Nothing
  • Frequently Asked Questions

The Hidden Chaos of Transitive Dependency Management

The Hidden Chaos of Transitive Dependency Management

The real headache isn’t the library you actually invited into your codebase; it’s the five others that library dragged in with it without asking permission. I call this the “uninvited guest” problem. You run a simple `npm install` or `pip install` thinking you’re just adding a lightweight utility for string manipulation, but under the hood, you’ve just opened a door to a sprawling, invisible web of code. This is where transitive dependency management becomes a nightmare. You might have 20 direct dependencies in your `package.json`, but your actual dependency tree likely contains hundreds of sub-dependencies that you didn’t vet, don’t understand, and certainly aren’t monitoring.

I learned this the hard way during a stint at a logistics startup. We had a minor version bump in a deep-level utility library that triggered a breaking change in a completely unrelated part of our stack. Because it was three levels deep, our automated tests didn’t catch it, and it only surfaced when the service started throwing 500s under heavy load. If you aren’t practicing strict dependency hell prevention—like using lockfiles religiously and auditing your tree—you aren’t actually in control of your software. You’re just riding a wave of third-party code and hoping the tide doesn’t go out while you’re standing on the beach.

How Third Party Libraries Become Your Biggest Liability

How Third Party Libraries Become Your Biggest Liability

We tend to treat a new library like a guest in our house, but after a few months, it’s more like a roommate who never pays rent and slowly starts moving your furniture. The problem isn’t just the code you actually imported; it’s the silent weight of everything that library brought with it. I’ve seen services crawl to a halt not because of our own logic, but because a deep-seated utility library three layers down decided to change its behavior in a minor patch. This is where managing third-party libraries stops being a convenience and starts becoming a liability. You think you’re adding a simple JSON parser, but you’re actually inviting an entire ecosystem of unvetted code into your runtime.

The real danger is the illusion of control. We run our tests, everything passes, and we ship. But we aren’t just shipping our code; we are shipping a massive, interconnected web of external logic. If you aren’t actively reducing technical debt by pruning unused packages and auditing what’s actually running in your container, you aren’t building a system—you’re building a house of cards. I’ve learned the hard way that if you don’t treat every dependency as a potential point of failure, you’ll eventually be the one sitting in front of a terminal at 2 AM wondering why a “minor update” just broke your entire deployment pipeline.

My survival guide for not letting a `npm install` ruin my weekend

  • Pin your versions and stop trusting “latest.” I’ve learned the hard way that letting a package manager pick the version for you is just inviting a breaking change into your codebase without an invitation. Use lockfiles, check them into git, and treat every version bump like a manual code review.
  • Audit your dependency tree before you merge. It’s easy to add one small utility library, but if that library brings in forty other transitive dependencies, you didn’t just add a tool—you added a massive, unvetted attack surface. If the tree looks like a jungle, find a different way to write that function.
  • Implement automated vulnerability scanning, but don’t let it become noise. Tools like Dependabot are great, but if they’re firing off alerts for CVEs that don’t even affect your execution path, you’ll start ignoring them. The goal is to find the signal in the noise before the security team finds you.
  • Keep a “dependency budget” in your head. Every new library is a long-term commitment to maintenance, security updates, and potential breaking changes. If you can solve the problem with ten lines of standard library code instead of a 5MB package, take the ten lines. It’s less “elegant” on paper, but it’s much easier to debug at 2 AM.
  • Document why a specific version or library was chosen. I’ve spent way too much time looking at a weirdly specific version constraint in a config file and wondering if it was a genius move or a mistake. Write a comment. Tell your future self—or whoever inherits this mess—exactly why that version is the only one that doesn’t crash the build.

What I’ve Learned from the Post-Mortems

Stop treating version numbers like suggestions; if you don’t pin your dependencies, you aren’t running your own code, you’re running whatever the internet decided to push to your build server this morning.

Audit your dependency tree not for “coolness,” but for surface area; every extra library is just another piece of code you didn’t write that can fail in ways you didn’t anticipate.

Accept that you will never have zero dependencies, so focus on making the ones you do have easy to replace or isolate before they become deeply coupled to your core business logic.

The Cost of Doing Nothing

The Cost of Doing Nothing in security.

At the end of the day, managing dependencies isn’t about achieving some theoretical state of perfect security or following a checklist from a security auditor. It’s about visibility. If you aren’t pinning your versions, auditing your transitive trees, or at least knowing exactly what code is running in your production environment, you aren’t actually in control of your system—you’re just hoping for the best. I’ve learned the hard way that “automatic updates” are often just a polite way of saying “unplanned downtime.” The goal isn’t to avoid third-party code entirely; it’s to ensure that when a library inevitably breaks, you have the telemetry and the version control necessary to fix it before the pager goes off.

I don’t expect you to go home and rewrite your entire service from scratch using only standard libraries. That’s not realistic, and frankly, it’s a waste of time. Instead, just start making the decision to be intentional. Treat every new dependency like a small, unvetted loan to your technical debt. If you take the time to document why you needed it and how it behaves, you aren’t just writing code; you’re building a map for the person who has to deal with the fallout six months from now. Usually, that person is me, or it’s you. Let’s try to make it a little easier on each other.

Frequently Asked Questions

If I start pinning every single version to avoid surprises, won't I just end up with a massive, unmaintainable technical debt nightmare when security patches roll around?

You’re right. Pinning everything blindly is just trading a midnight outage for a slow death by technical debt. If you pin a version and forget it, you’re essentially running a museum of old vulnerabilities.

How do you actually balance the need for automated dependency updates with the reality that a "minor" patch can still break your entire deployment pipeline?

I use a tiered approach. I never let a bot merge directly to main, no matter how much the green checkmarks tempt me. I automate the detection of updates, but the application stays manual or gated by a staging soak period. I treat every “minor” patch as a potential breaking change. If it’s a core library, it gets a manual smoke test. If it’s a utility, I let the CI run the full suite. Trust the tests, but don’t trust the version numbers.

At what point does the overhead of auditing every single transitive dependency become a waste of engineering time compared to the actual risk?

It becomes a waste of time the moment you start auditing for “best practices” instead of actual risk. If you’re manually checking every utility library in a private, internal tool, you’re wasting cycles. I draw the line at the perimeter: if it’s internet-facing, handles PII, or touches our payment flow, I audit it. For everything else, I rely on automated scanners and lockfiles. Don’t let the pursuit of perfect security paralyze your actual feature work.

What’s the practical way to vet a library's long-term health before it becomes a permanent, unfixable part of our core services?

I don’t look at GitHub stars; they’re a vanity metric. I look at the commit history and the issue tracker. If the last meaningful change was eighteen months ago, or if pull requests sit unmerged for weeks, that library is a ticking time bomb. I check the “bus factor” too—if one guy in a basement is the only one committing, you’re inheriting his personal technical debt. If it’s not being actively maintained, don’t let it into your core.

How to mock an external service locally.

Working Offline From Somebody Else Api

Posted on June 25, 2026November 7, 2026 by Tomasz Wierzbicki

I was sitting in my kitchen at 3:15 AM, staring at a terminal window that refused to cooperate, wondering why I had ever thought hitting a live staging API during local development was a “good enough” shortcut. We’ve all been there: your tests are passing, but the second you actually try to run the code on your machine, the whole thing falls apart because a third-party sandbox is down or, even worse, it’s returning unexpectedly slow responses. Most tutorials online try to sell you on complex, heavy-duty service virtualization platforms that take longer to configure than the actual feature you’re building. But honestly, if you’re just looking for how to mock an external service locally without losing your mind or your entire weekend, you don’t need a massive enterprise suite; you just need a predictable way to simulate failure.

I’m not here to pitch you a specific framework or tell you that one tool is the “industry standard.” Instead, I want to walk through the practical, slightly battle-scarred ways I’ve handled this across different teams—from simple HTTP interceptors to running lightweight containers. My goal is to show you how to build a setup that actually prevents those middle-of-the-night outages by forcing you to confront edge cases before they hit production.

Table of Contents

  • Simulating Third Party Api Responses Before They Break Production
  • The High Cost of Failing to Use Test Doubles in Software Development
  • A few things I’ve learned the hard way
  • What I’ve learned the hard way
  • The Trade-off is the Point
  • Frequently Asked Questions

Simulating Third Party Api Responses Before They Break Production

Simulating Third Party Api Responses Before They Break Production

The problem with relying on a live sandbox or a staging environment from a vendor is that those environments are rarely as stable as their marketing materials claim. I once spent an entire Tuesday afternoon chasing a “bug” in my own logic, only to realize the third-party payment gateway was undergoing unscheduled maintenance. When you’re simulating third-party API responses, you aren’t just trying to save on network latency; you’re trying to create a deterministic world where your tests actually mean something. If the external service is down, your CI/CD pipeline shouldn’t be down with it.

To do this properly, I’ve moved away from just hitting a real endpoint and hoping for the best. Instead, I lean heavily on test doubles in software development to represent those external boundaries. For simple cases, I’ll use unit testing with dependency injection to swap out a real client for a lightweight stub. But when the logic gets complex—like needing to test how my system handles a 503 error or a malformed JSON payload—I reach for more robust service virtualization techniques. It’s about building a controlled environment where I can intentionally break things, because if I don’t break them on my machine, they’ll definitely break in production.

The High Cost of Failing to Use Test Doubles in Software Development

The High Cost of Failing to Use Test Doubles in Software Development

I’ve learned the hard way that skipping test doubles in software development isn’t just a technical shortcut; it’s a debt that carries a massive interest rate. When you rely on live sandboxes or staging environments for your daily development, you aren’t just testing your code—you’re testing the entire internet. I once spent an entire afternoon staring at a failing build, only to realize the external payment gateway was undergoing scheduled maintenance. My code was fine, but my productivity was zero. When your local environment is tethered to a third party’s uptime, you’ve essentially handed over control of your sprint velocity to someone else’s DevOps team.

The real cost, however, shows up during the debugging phase. Without proper service virtualization techniques, you end up chasing ghosts. If a bug only triggers when an external API returns a 503 or a malformed JSON payload, you can’t easily replicate that on your machine without a mock. You end up writing “defensive” code that is actually just guesswork. By failing to invest in improving developer productivity with mocks, you’re choosing to spend your time troubleshooting network latency and API rate limits instead of actually building features. It’s a slow, expensive way to learn how to write resilient software.

A few things I’ve learned the hard way

  • Don’t just mock the “happy path.” I’ve wasted far too many hours debugging code that worked perfectly in staging only to have it choke on a 503 or a malformed JSON payload in production. Your mocks need to be intentionally annoying sometimes.
  • Avoid the temptation to write complex logic inside your mocks. If your mock starts having its own `if/else` statements to simulate business logic, you aren’t testing your code anymore; you’re just debugging a second, poorly written version of the service you’re trying to replace.
  • Use tools that actually sit on the wire. I used to rely heavily on library-level mocking (like mocking a specific class or function), but that’s brittle. If you change a dependency, your tests still pass even though the real network call would fail. I prefer using something like Prism or WireMock that actually intercepts HTTP traffic.
  • Keep your mock definitions close to the code. I once inherited a repository where the mocks were buried in some massive, centralized “test-utils” folder that nobody dared to touch. Now, I try to keep the contract definitions near the client code so they don’t drift apart over six months of refactoring.
  • Treat your mocks as a contract, not a suggestion. The moment your external provider changes their API schema and your local mocks stay the same, your tests become a lie. It’s worth setting up a periodic “contract test” that runs against the real sandbox environment just to make sure your mocks haven’t become obsolete.

What I’ve learned the hard way

Stop relying on “live” sandbox environments for your local development; they are too slow, too flaky, and they will eventually fail you right when you’re trying to push a hotfix.

A good mock isn’t just about returning a 200 OK; it’s about being able to force a 503 or a timeout so you can actually see if your error handling works before a real provider goes down.

Documentation for your mocks is just as important as the code itself—if I can’t understand what a mocked response is supposed to represent six months from now, the mock is useless.

The Trade-off is the Point

The Trade-off is the Point in testing.

At the end of the day, mocking isn’t about achieving some theoretical state of perfect test coverage; it’s about control. We’ve talked about why relying on live third-party sandboxes is a recipe for flaky CI pipelines and why failing to simulate edge cases eventually leads to that 2 AM pager duty alert. You can go the route of heavy integration tests if you want to prove the whole world works together, but if you want to actually build features without your local environment constantly tripping over a rate-limited API, you need reliable test doubles. It’s a trade-off between the absolute fidelity of a real network call and the predictable, boring stability of a mock, and in a production environment, I will choose boring every single time.

I’ve spent enough time chasing ghosts in the machine to know that most “unexplainable” bugs are just the result of an unhandled state we assumed would never happen. Use mocks to force those states. Don’t just test the happy path where the API returns a 200 OK; test the timeout, the malformed JSON, and the 503 error. If you write your tests to expect the worst from your dependencies, you won’t be surprised by the reality when they actually fail. Build the safety net now, so you can actually sleep through the night later.

Frequently Asked Questions

How do I stop my mocks from becoming "liars" that pass locally but fail the moment they hit the real API?

The problem is that mocks are static snapshots of what we think the API does, not what it actually does. I’ve been burned by this: a mock returns a 200 OK with a perfect JSON payload, but the real service starts returning 429s when rate-limited or changes a field from an integer to a string. To stop the lying, you have to move toward contract testing. Use something like Pact or even just a shared schema definition. If the real API drifts from your mock, your tests should fail immediately. Don’t trust your own assumptions; trust the schema.

At what point does mocking a service become more work than just spinning up a lightweight container?

It’s a tipping point I hit a lot. If you’re just mocking a simple JSON response, a stub is fine. But the moment you need to test complex state transitions—like a payment moving from `pending` to `captured`—maintaining that logic in a mock becomes a second, buggy implementation of the actual service. At that point, I stop fighting the mock and just spin up a lightweight container. It’s better to have a real, containerized dependency than a “perfect” mock that lies to you.

Is there a way to record actual production traffic and replay it for my local tests without leaking sensitive data?

I’ve actually tried this. It’s a tempting way to get “real” data, but unless you’re extremely careful, you’ll end up with PII sitting in your git history or a local JSON file. I usually use a tool like GoReplay to capture the traffic, but you have to pipe it through a scrubbing script immediately. It’s a lot of overhead to set up, so honestly, unless your API logic is incredibly non-deterministic, I’d stick to well-defined mocks.

How do I handle edge cases like rate limiting or 503 errors in a mock without writing a massive, unmaintainable mess of test code?

The mistake I see most often is trying to bake every error scenario into a single, massive mock function. That’s a recipe for a maintenance nightmare. Instead, I use a simple stateful mock or a small middleware layer. I set up a few predefined “scenarios”—like `SUCCESS`, `RATE_LIMITED`, or `SERVER_ERROR`—and just tell the mock which state to inhabit for that specific test. It keeps the test code clean and the failure logic isolated.

  • Previous
  • 1
  • …
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • …
  • 22
  • Next

Recent Posts

  • The Signs You Will Ignore Until You Cannot
  • Crash Early Rather Than Corrupt Quietly
  • A Deadline Needs a Witness
  • Where the Evenings Actually Went
  • Teaching Yourself Without a Syllabus
  • Read Both Sides Before You Pick One

Categories

  • Career (44)
  • Code Habits (45)
  • Debugging (43)
  • Side Projects (45)
  • Tooling (43)

Archives

  • November 2026
  • October 2026
  • September 2026
  • August 2026
  • July 2026
  • June 2026
  • May 2026
  • April 2026
  • March 2026
  • February 2026
  • January 2026
© 2026 theboreddev.com | Powered by Minimalist Blog WordPress Theme