{"canonical_url":"https://engineer.company/glossary/defect/","content_markdown":"# Defect\n\n## What it is\n\nA defect is something wrong inside a piece of work that makes the work behave differently from what\nit was meant to do, or leave out part of what it was meant to do. Most programmers call it a bug,\nand testers and standards also write fault or flaw.\n\nThe important word there is _work_. A defect can live in source code, and it can just as well live\nin a requirement that contradicts another requirement, a design that cannot carry the load it was\ndrawn for, a configuration file, a test that asserts the wrong value, or a manual that describes a\nbutton the product dropped two releases ago. Wherever it lives, a defect belongs to the thing\nitself, and it is present whether or not anybody has noticed it.\n\nTesting vocabulary keeps three neighbouring words apart, and the separation earns its keep. A person\nmakes an error: a misread specification, a wrong assumption, a slip of the keyboard. The error\nleaves a defect behind in whatever that person produced. When the defective part runs under\nconditions that expose it, the product behaves wrongly, and that visible wrong behaviour is a\nfailure. The chain runs in one direction and can stop at any link. A defect in a branch that never\nexecutes, or one that needs an input nobody sends, can sit in a codebase for years without causing a\nsingle failure.\n\nWhat counts as wrong depends on what was expected, and expectations reach further than the written\nspecification. The product quality model in ISO/IEC 25010 describes functional suitability as the\ndegree to which a product “provides functions that meet stated and implied needs when used under\nspecified conditions”. It splits that into completeness (do the functions cover the specified tasks\nand the intended users' objectives), correctness (are the results accurate) and appropriateness (do\nthe functions help get the task done). A wrong total is a correctness problem; a report nobody can\nexport is a completeness problem. The same model treats reliability as a separate characteristic,\nwith faultlessness, availability, fault tolerance and recoverability among its parts, so a product\nthat computes the right answer and then crashes twice a day still has defects.\n\nA regression is a defect with a history: something that worked and was broken by a later change. It\nearns its own name because it brings a clue that an original defect lacks, a last version known to\nbe good.\n\n## Why it matters\n\nThe cost of a defect depends mostly on where it is found. Caught by the person writing the code, it\ncosts a minute and leaves no trace. Caught in review, it costs a conversation. Caught by a customer,\nit costs the failure itself, the support ticket, the investigation, the fix and some trust, and if\nit did real harm it has become part of an incident. Type systems, linters, tests and code review all\nwork on the same line, trying to move the moment of discovery closer to the moment the defect was\nwritten.\n\nDefects also come in families. The mistake behind one usually has relatives: the same misread\ninterface called the same way in six places, the same unit confusion copied into every new module,\nthe same unchecked assumption in each request handler. The productive question after a defect is\nless where the broken line is than what made that line easy to write, and where else the same thing\nhappened.\n\nAnd defects come back. Code changes constantly, and a repaired defect can return through a refactor,\na merge or a dependency upgrade. A test written to fail on the defect and pass on the repair turns\nthe repair into a lasting property of the build. When a regression appears anyway, the version\nhistory becomes a search space: `git bisect` runs a binary search over the commits between a known\ngood and a known bad version, so a range of a thousand commits narrows to the one that introduced\nthe bug in about ten test runs.\n\nSome defects are security problems as well. MITRE's Common Weakness Enumeration catalogues\nweaknesses, each of which it describes as “a condition in a software, firmware, hardware, or service\ncomponent that, under certain circumstances, could contribute to the introduction of\nvulnerabilities”. Plenty of entries on that list are ordinary defects that an attacker has a use\nfor: a missing bounds check, user input passed unescaped into a query, an authorisation step skipped\non one route.\n\n## What it looks like in practice\n\nThe defects that cost most on this site were the ones every automatic signal called fine. An audit\nturned up\n[eleven accessibility defects that the automated rules had passed](/portfolio/the-accessibility-faults-your-checker-misses/),\nbecause each was a property of how a page rendered rather than of what its markup said. Two of them\nsat in the checks themselves. Every window the layout check opened was 900 pixels tall, so a phone\nheld sideways at 852 by 393, with seven pixels between two items, had never been looked at; and the\nrule engine had been running 70 of its 105 rules. Each defect went into a ledger together with the\nrule it produced, so the work closes a class of mistake and not just one occurrence. Once the layout\ncheck itself was repaired, it failed 128 times across three languages.\n\nA second defect produced no symptom at all. The site has a dark theme by default and a light theme\nfor readers whose system asks for one, and its full-page cover is built from three layers in the\ndark theme. A small structural check that counts the layers each theme paints\n[found the light theme drawing only two](/portfolio/found-the-light-theme-missing-a-whole-layer/)\non its very first run. The overlay had been absent since the light theme was written. Nothing threw\nan error and every page rendered, and a background with one layer fewer passes for a deliberate\nchoice, so for months there was no reason to look. The repair was one rule; the check is what keeps\nit repaired.\n\nKeeping repairs in place is the job of the repository's guard engine, where one rule ties every bug\nfix to evidence:\n[a commit marked as a fix has to bring a test that fails without it](/portfolio/built-a-268-check-guard-engine-for-the-repo/).\nThe guards also have 146 tests of their own, because a faulty guard can let through the changes it was meant to reject and appear to be working.\n\n## Where it goes wrong\n\n**The occurrence gets fixed and the class stays open.** The reported line is corrected, the ticket\ncloses, and three siblings of the same mistake keep waiting elsewhere in the code. After each fix,\nsearch for the pattern that produced it, and where a machine can recognise the pattern, turn the\nsearch into a check.\n\n**A repaired bug returns.** A refactor half a year later restores the old behaviour, because nothing\nrecorded what the repair was protecting. Write the test before the fix, watch it fail on the old\ncode, and keep it in the suite for good.\n\n**The checker carries the defect.** A rule set that quietly loads a fraction of its rules, a list of\ntest windows that all share one height, an assertion that checks what the code does instead of what\nit should do: each reports success while the defect sits in plain view. Give checks tests of their\nown, and read from the tool's own output which rules actually ran.\n\n**Coverage stands in for correctness.** A suite can execute every line and still pass a wrong result\nwhen no assertion looks at the outcome, and code that meets its written specification can still miss\nan implied need. Use coverage to find code that nothing tests, and judge a test by the defects it\nwould catch.\n\n**“Works as designed” closes a real report.** The behaviour matches the specification, the report is\nrejected, and the defective work product was the specification all along. When the requirement or\nthe design is where the problem lives, file the defect against that, so the repair happens at the\nsource.\n\n## Further reading\n\n- [Defect](https://glossary.istqb.org/en_US/term/defect) — the ISTQB definition used in software\n  testing, with its synonyms and the related terms error and failure.\n- [ISO/IEC 25010](https://iso25000.com/index.php/en/iso-25000-standards/iso-25010) — an overview of\n  the product quality model and each characteristic's sub-characteristics, functional suitability\n  and reliability among them.\n- [git-bisect](https://git-scm.com/docs/git-bisect) — Git's manual for the binary search that finds\n  the commit that introduced a bug, including automated runs with a test script.\n- [About CWE](https://cwe.mitre.org/about/index.html) — what the Common Weakness Enumeration is, how\n  its list of software and hardware weaknesses is organised and who runs it.\n\n\u003chttps://engineer.company/glossary/defect/\u003e\n","date_modified":"2026-11-12T05:34:23Z","description":"Where a defect ends and a failure begins, why each fix should carry a test that fails without it, and why the costliest defects render without a single error.","formats":{"gemtext":"https://engineer.company/glossary/defect/index.gmi","gopher":"https://engineer.company/glossary/defect/gophermap","html":"https://engineer.company/glossary/defect/","json":"https://engineer.company/glossary/defect/index.json","markdown":"https://engineer.company/glossary/defect/index.md","pdf":"https://engineer.company/glossary/defect/index.pdf"},"kind":"page","language":"en","title":"What is a defect?","url":"https://engineer.company/glossary/defect/","version":1}