Most of the errors developers notice in real codebases cluster into a small set of repeatable fault families, and the cause is usually a broken assumption rather than a typo. The assumption might be about null values, about how timezones behave, about what a library actually returns, or about concurrency. Once you learn the families, you can scan unfamiliar code and predict where it will break before you run it. This is the answer an experienced engineer would give to that question: not a list of bugs, but a taxonomy of causes you can watch for.

The error patterns I keep seeing and the habits that produce them

I keep a private scratch list of every meaningful error I've debugged across roughly a decade of professional work, across PHP, JavaScript, Python, Java, and Go codebases. The list is short. Faults recur across languages and teams with almost boring regularity. When a bug takes longer than an hour to fix, it usually belongs to one of the nine families below.

Language choice changes the symptom, not the cause. Null pointer exceptions, undefined variable warnings, and TypeErrors all trace back to unguarded inputs from an untrusted boundary. Concurrency deadlocks in Java and race conditions in JavaScript's event loop share an ancestor: state shared without a synchronization contract. Skip the language lens and the taxonomy tightens up.

The most useful classification divides errors by origin, not severity. Origin means "what assumption did the author make that wasn't true?" That question isolates the cause from the symptom, which matters because the symptom is where people spend their debugging energy. Ask ten developers to name their most common error and you'll get ten symptoms. Ask them to name the assumption behind it and the room goes quiet.

The rest of this article walks through nine families with the assumptions that generate them, plus a runtime-versus-design distinction that saves investigation time. For readers new to a codebase, this list doubles as a review checklist. For readers maintaining inherited code, it doubles as a triage tool when a wild error surfaces at 2 a.m.

Why the same faults reappear across languages and teams

Every codebase sits at a boundary between the code you own and the world you don't. That world includes user input, network responses, disk contents, and library behavior that drifts with version upgrades. Most code, however, is written with the optimistic assumption that the world behaves the way the developer last saw it behave. Errors live in the gap between that assumption and reality.

A concrete example: in JavaScript, typeof null === "object" β€” a legacy quirk preserved for backwards compatibility, documented in MDN's reference on the typeof operator. A developer who has only read textbook descriptions of types will write if (typeof user === "object") to guard a null check. The guard passes. The next line throws. The error looks random until you trace the assumption back to a language quirk nobody taught that developer.

Teams amplify the problem. A library update that returns an empty array instead of null will silently break every check written against the old contract. The error doesn't appear in the changelog, so nobody knows to look. Multiply that across a modern project with hundreds of transitive dependencies and you get the environment most production bugs are born in.

The fix isn't heroic. It's procedural: treat boundaries as adversarial, ask what the boundary can return, and test against the surprising answer. That mental habit prevents more errors than any type system, because types only catch what you told them to catch.

How null and undefined failures evade even careful developers

Null and undefined bugs most often come from two flawed assumptions: that "missing" is a single thing, and that optional chaining always saves you. In JavaScript, null and undefined are distinct values with distinct behaviors β€” null means "empty on purpose," undefined means "not provided." A field that arrives as undefined from a missing API property and a field that arrives as null because the backend explicitly cleared it can send downstream logic down two different paths.

The classic crash is deeper than obj.prop when obj is null. That error announces itself on the first run. The nastier variant is a "silent fallback" β€” code that uses || where it should use ??. value || "default" replaces 0, false, and "" with the default because they're falsy. value ?? "default" only replaces null and undefined. A form field set to 0 (a quantity, say) silently becomes the default string.

Falsy input value || "default" result value ?? "default" result
0 "default" (wrong) 0 (correct)
false "default" (wrong) false (correct)
"" "default" (wrong) "" (correct)
null "default" "default"
undefined "default" "default"

The other pattern is optional chaining masking absence downstream. user?.profile?.name returns undefined if any link in the chain is missing. That's often the intent, but it hides whether name was ever fetched. A later line that does user.profile.name.toUpperCase() throws, and the stack trace points at line 400 while the cause happened at line 20.

Prevention is a mix of tooling and design. TypeScript's strictNullChecks flag makes null and undefined unassignable to non-nullable types, catching a large share of these at compile time β€” turn it on in tsconfig.json before the first commit, not after the codebase has grown. For dynamic languages, add a boundary validator at every external input: API responses, form posts, environment variables.

Input validation gaps that turn user data into runtime exceptions

Unvalidated input is the single most common origin of runtime exceptions in any codebase I've worked on. The assumption behind it is always the same: "the client sends what it says it sends." Users, bots, and especially automated scanners do not cooperate with that assumption. A three-minute script can POST a form with a missing required field, a 2 MB string where a 5-character code is expected, or a value that starts life as a query string and ends life embedded in a database query.

Two specific patterns surface constantly. First, missing type checks at the boundary β€” accepting whatever JSON is sent and passing it straight into a typed function. Second, length and format checks bolted on late, after the data has already traveled through transformations that strip the metadata needed to validate it. Once a string has been trimmed, encoded, and re-parsed three times, nobody can say whether it originally contained a newline.

A worked example from a recent project: an endpoint accepted an amount field, converted it with Number(amount), and then compared it to a business rule of "greater than zero." The client sent "0x10". JavaScript's Number("0x10") evaluates to 16 β€” valid hex notation. The value passed the positivity check, was submitted, and a downstream service received a number in the field where a currency amount was expected. The bug wasn't a missing null check; it was a type-coercion footgun.

Validation belongs in one place and one time: at the entry point, before data is trusted. Use a schema library suited to the language β€” Zod in TypeScript, Pydantic in Python, Bean Validation in Java β€” and define the schema by specification, not by observation of what clients happen to send today. Confirm the strictest version of your runtime's parsing behavior in that library's docs, because coercion rules differ per version and per library, and a silent upgrade can widen what's accepted.

Type coercion and implicit conversion bugs that survive review

Implicit conversion produces some of the most reviewed yet most persistent errors, because a passing code review may not catch what a runtime will do. The assumption reviewers make is that types are what they look like. In weakly typed languages, arithmetic and equality operators convert their operands according to rules that aren't obvious from the code shape.

JavaScript's coercion corners are well-known but still catch professionals. 0.1 + 0.2 produces 0.30000000000000004, a floating-point artifact (documented in MDN's JavaScript arithmetic reference). [] + [] stringifies both arrays and returns "". "5" - 2 returns 3 because subtraction forces numeric conversion, while "5" + 2 returns "52" because addition prefers string concatenation when either operand is a string. Each is a one-line demo; each also represents a class of production bug where a stringified number slips through a code path and mutates a calculation.

PHP has version-specific traps worth knowing about, because they've changed across major releases. == between certain string and number values behaved differently in PHP 7 than in PHP 8, and the migration guide for PHP 8 explicitly documents the change in string-to-number comparison behavior. Code written in PHP 7 and upgraded without review can start comparing "abc" == 0 as false instead of true, flipping logic silently. That's not a bug the developer wrote; it's a bug the runtime change introduced. Always run the language's migration guide as a checklist before jumping a major version.

The mitigation is a style discipline plus linting. Prefer strict equality (=== in JavaScript, === in PHP) and enable a linter rule that fails the build when loose equality appears. Wrap arithmetic on external values in explicit Number() or parseInt() calls with a radix argument. For currency, use integer minor units (cents) or a decimal library β€” never floating-point. Rules like these feel bureaucratic until the first incident; afterward, they're the cheapest lines in the codebase.

Async and concurrency faults: races, orphans, and misread state

Concurrency errors cluster around three assumptions: that code runs in the order it's written, that state can't change between two lines, and that awaiting a promise means everything inside the promise has settled. None of those are true in a real async runtime, and each produces a distinct family of bugs.

The most common form is the race condition with a shared cache or object. Two requests arrive, both find the cache empty, both call the expensive fetch, and both write the result. The correct pattern is a single-flight or promise-memoization primitive, but the wrong pattern is far more common because it looks correct: read, check, write, in three sequential lines with no lock between them. On your laptop with one request, it's fine.

The second form is dangling async work β€” a promise started and never awaited. In Node.js and browsers, an unawaited promise rejection can escape error handlers, and process termination on unhandled rejection is configurable and has changed across Node.js releases. A function that fires and forgets a database write will occasionally succeed in mystery order, occasionally fail in silence, and always confuse whoever debugs it.

Change the second line to await db.write(user); and the contract becomes honest. Confirm your runtime's current unhandled-rejection default in its release notes before relying on it, because the default has flip-flopped across major Node.js versions.

The third form is the mutated shared state pattern in frameworks that claim immutability but expose mutable references β€” commonly seen when a Redux reducer returns a nested object without spreading it. State updates that appear to run "later" actually share the same reference, so a change made after the update call also lands inside the previous state. Trace tooling helps; discipline helps more. Treat shared state as rented property, never owned.

Dependency, version, and environment drift that breaks working code

Dependency and environment drift errors surprise teams because the code didn't change β€” the world around it did. The assumption is that yesterday's working build is tomorrow's working build. Lockfiles, container tags, and runtime versions make this assumption true in some setups. Bare semver ranges make it false in others.

The famous case is left-pad, a small npm package whose unpublishing in March 2016 broke builds across many JavaScript projects β€” documented at the time by npm itself and covered in numerous retrospectives. The broader lesson stuck: an 11-line utility pulled in by a chain of transitive dependencies can become a load-bearing pillar without anyone noticing. Version pinning and lockfile commits are the mitigation.

Practice Failure mode it prevents Where to configure it
Committing lockfile to git Silent upgrade of transitive dependencies package-lock.json, yarn.lock, poetry.lock
Pinned base image tag (not latest) Runtime environment changes between builds Dockerfile FROM line
Node/Python version file Local and CI divergence .nvmrc, .python-version
Peer-dependency audit before upgrade Breaking API changes in majors npm ls, pip check

The other family is environment drift between local, CI, and production. A developer runs Node 20, CI runs Node 18, production runs Node 16 β€” three subtly different runtimes. A newer syntax passes locally and fails on the older engine with a syntax error that the build log mislabels. Naming the runtime version explicitly in a file committed to the repo prevents this; it's the cheapest preventive measure available.

Boundary errors: how your code, its libraries, and its data disagree

Boundary errors happen when two systems agree on shape but disagree on meaning. The shape is the JSON key; the meaning is what the value represents. Common forms include a service that returns dates as strings in local time while your parser assumes UTC, a serializer that omits null fields while your client checks for their presence, and a currency service that returns minor units while your front-end expects major units.

A specific pattern worth seeing in full: an API returns created_at as "2026-01-01T00:00:00" with no timezone offset. Your JavaScript new Date("2026-01-01T00:00:00") β€” because the string lacks an explicit Z or offset β€” parses in the browser's local time. A user in Tokyo sees a different "creation date" than a user in London, and any "created today" filter disagrees with reality for half of every day. The bug is invisible until a global rollout, then it becomes five support tickets a week.

The fix has two parts. First, agree on a format specification at the boundary β€” ISO 8601 with explicit offset, documented in the API contract β€” and validate against it at ingest. Second, make the parser strict. In JavaScript, use a library like date-fns or Temporal (the standardized date API in the ECMAScript specification) that fails loudly on missing timezone info rather than guessing. In Python, use datetime.fromisoformat with an explicit post-parse check that tzinfo is set. Strict parsing converts silent bug into visible error, and that's a promotion.

Serialization boundaries deserve equal care. If your API properly omits fields set to null, your client can't tell "field absent" from "field dispatched with null value." Either preserve nulls in the wire format or ensure both sides treat absence as missing β€” and document which. The cost of that decision is one paragraph in an API doc; the cost of not making it is a bug every six months.

Silent failures and swallowed exceptions that hide root causes

Swallowed exceptions are the most damaging class of error in production, because they delay discovery until the symptom becomes severe. The assumption is that catching and logging is safer than crashing. In practice, a swallowed error in a background job means the job has been silently failing for weeks before anyone checks the queue depth.

The archetypal pattern is try { ... } catch (e) { } with no log line, or the slightly better catch (e) { console.log(e); } where the log goes to a stream that's unreachable in production. In languages with checked exceptions, catch (Exception e) { } and continue-with-null is common in code written under deadline pressure. Java's _ variable pattern and Kotlin's runCatching { ... }.getOrNull() both make the swallow look intentional.

The worst variant is logging that lies. A catch block that logs "User fetch failed, using cached data" when there is no cached data β€” that's a message written by a developer who believed the fallback existed. Six months later, the message is still there, the cache is gone, and the log line is technically accurate and completely misleading.

Swallowing pattern Recommended replacement
catch (e) { } catch (e) { logger.error("operation failed", { error: e }); throw e; }
try { ... } catch { return null; } Return a typed error result, or rethrow with context
Log-and-continue in a payment flow Fail loudly; let the caller decide the fallback
Bare except: in Python except SpecificError as e: with logging and re-raise

The fix is a policy, not a patch. Treat every catch block as a decision that must name a fallback that actually works, or escalate. If a fallback doesn't exist, crash β€” a crashed process is diagnosed in minutes, a silently degraded one can mislead for months. Log at the boundary with structured context, and get the entire team to read the exception handling guide that ships with every serious language runtime.

How to classify an error before you try to fix it

The classification matrix that saves the most time splits errors into four cells along two axes: runtime vs design, and local vs boundary. Runtime-local errors (a null deref inside a function you control) are usually fixed in under an hour with a null guard and a test. Runtime-boundary errors (a JSON shape that surprised you) need contract validation and a designated owner. Design-local errors (a class hierarchy that can't express a needed state) are refactors. Design-boundary errors (two services with incompatible domain models) are architecture work.

The value of the split is that it moves the effort estimate off the symptom. A null deref in the wrong cell can take three weeks; a null deref in the runtime-local cell takes thirty minutes. Investigations that don't name the cell tend to drift into rewrites β€” a common and expensive misdiagnosis.

Apply the matrix at triage, before opening the debugger. Read the stack trace, note the faulting line, and ask: is this a wrong value or a wrong type? Does the wrong value enter from outside the function that crashed, or is it generated by the function itself? Is the shape assumed here documented as part of an interface contract? Three questions, thirty seconds, and the work estimate usually falls out.

The classification habit also fixes the wrong-target problem. Code review catches design errors far more readily than runtime errors; tests catch runtime errors far more readily than design errors. If a team is finding design errors during production incidents, that's the signal to invest in design review, not more tests. No amount of testing closes the design gap, and no amount of design review catches the coerced-number bug on line 400 of a parser.

Review checklist and preventive practices that cut recurring error families

The checklist below is what I hand new team members on day one. It's not exhaustive, but it catches the majority of error families that victims inherit from predecessors. Run it during review; run it again before any release that touches a boundary.

1: Every external input (HTTP body, query string, response payload, env var) has a schema validator applied before use. 2: Every catch names a fallback that exists and is tested, or rethrows with structured context. 3: Every promise-returning call in an async function is either awaited, returned, or explicitly marked fire-and-forget with error handling. 4: Every dependency has a lockfile entry and a pinned runtime version in .nvmrc, .python-version, or equivalent. 5: Every date/time value is either consumed with an explicit timezone or rejected by a strict parser. 6: Every number that represents money is stored as integer minor units or decimal β€” floating-point arithmetic on currencies fails review. 7: Every || fallback default in a config or form path has been re-checked against the falsy inputs the field can legally take. 8: Every language-major upgrade runs the official migration guide before code merges.

Use this checklist as a search plan, not a gate. Any binary "approved/rejected" gate invites workarounds; a checklist that developers actually use reduces error discovery time. Track which items fail most often in your team's history and add a lint rule or a CI check to automate the recurring ones.

The most underrated preventive practice is writing one test per historical production bug. That test's purpose isn't to verify a specific behavior β€” it's to reproduce the scenario the bug was born from. Over a few years, those tests form a fault-family map that no book can match. When a new developer asks "what kinds of errors appear in this codebase?" the test suite is the literal answer.

FAQ

What kinds of errors do most developers notice in their codebases?

Runtime errors like null dereferences, TypeErrors, and unhandled rejections dominate the first three years, while design errors like wrong abstractions and boundary contract mismatches dominate after. The balance shifts because runtime faults are caught by tests, but design faults escape because the abstraction was already trusted. Track which type appears in your last ten post-incident reviews; if more than three are design faults, invest in design review rather than coverage.

What actually causes errors to occur in code?

A broken assumption at a boundary is the root cause for most errors β€” missing, mistyped, or untrusted data enters at a system boundary and hits code written with optimistic expectations. The other common cause is that the runtime environment changed while the code did not. Writing your tests against boundary surprises and pinning your dependencies closes both causes.

Is it true that adding a null check before every line prevents most errors?

No, blanket null checks are a symptom patch, not a fix, and they usually make the code harder to read without addressing the real problem. The stronger move is strictNullChecks in TypeScript or an equivalent (Python's Optional types, Kotlin's null safety) so the type system forces you to handle null exactly where it can occur. Checks applied everywhere catch nothing specific and hide the true origin.

What is the hardest concurrency bug to diagnose?

The hardest is a race condition that only manifests under load, because the same code will pass every test on a developer laptop and fail intermittently in production. It usually involves shared state behind a lockless read-check-write pattern. Once you spot the pattern, the fix is a single-flight primitive or a proper mutex, and the diagnostic tool is application-level tracing, not logging.

How much time does a typical dependency upgrade incident cost?

A single breaking dependency upgrade can consume anywhere from a few hours to several developer-weeks depending on how much of the codebase touches it. The variation comes from which cell of the classification matrix the failure lands in: a runtime-local break is a day's work; a design-boundary break can cascade across services. Prevent the worst cases with lockfiles and a peer-dependency audit before every major upgrade.

Can I rely on static analysis tools to prevent every error type discussed here?

No, static analysis catches type and linting errors well but misses boundary drift, environment differences, and concurrency faults because those depend on runtime facts the analyzer can't see. Combine static analysis with boundary validation, integration tests, and one test per historical bug. Tools narrow the frequency of one family; they never eliminate the wider set.

What is the single most effective change a team can make to reduce recurring errors?

Bound every external input with a schema validator at the system's edge, then fail loudly when the schema is violated. That single change eliminates input-driven runtime exceptions, silent fallbacks, and half of the boundary contract mismatches in one policy. Add one test per historical bug on top and the trajectory of error frequency bends downward within a quarter.

A closing note on scope

This article is general engineering education, not a security, compliance, or legal opinion. Specific failure modes, acceptable designs, and required protections depend on your stack, jurisdiction, and threat model, so confirm details against the official documentation and release notes of the runtime, framework, and dependencies you actually use, and consult a qualified professional for anything with regulatory or safety impact. If your work touches systems where a bug could cause personal harm, stop and get a qualified review before shipping.