October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Why My Validation Check Passed a Broken Result

A count can match even when extracted fields are wrong. This example shows why validation needs the right invariant and evidence independent of the instrument being checked.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A validation check can pass a broken result when the defect preserves the property the check measures. In a field-extraction example, a count matched even though a regular expression renamed one field. The fix is to test the right invariant—and to use evidence the instrument under test did not produce.

How a count check missed a renamed field

Mahiro Hirakawa describes writing a reconciliation to catch a filter that silently dropped fields. The check compared how many fields the type declared with how many the filter matched. That sounds useful, but it only verifies a count.

As an Amazon Associate I earn from qualifying purchases.

The example includes the field risk-level. The regular expression w+=S+ does not treat a hyphen as part of the field name. It can therefore match level and attach the value to that wrong name. The field is not absent from the output; its identity has changed. Because the filter still emits five fields, the count comparison passes.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Hirakawa’s demonstration reports five fields for both the good and renaming cases, and ten for the duplicate-emission case. These are illustrative outputs, not general statistics. Read Hirakawa’s account on DEV Community.

What different checks can and cannot detect

Check What it verifies Example failure it can catch What can still pass
Count comparison Number of declared and matched fields A duplicate-emission case that changes the count A rename that leaves the count unchanged
Identity comparison Whether expected field names appear in the output A missing or renamed field A wrong value attached to a correctly named field
Value validation Whether observed values satisfy the expected meaning or constraints A correctly named field with an incorrect value, if the validation covers that error Errors outside the validation’s rules

The two example defects preserve different properties. Renaming preserves the number of fields but breaks the set of names. Duplicate emission can leave the set of names present while changing the count. A count-only check and a name-only check therefore have different blind spots.

Compare the output with declared identities

Hirakawa’s proposed improvement is to compare declared field names with the names found in the extracted result and raise an error when a declared name is missing. That detects the illustrated rename because risk-level is absent from the output under its declared identity. A duplicate that changes the count is detectable by the count reconciliation; checking identities also makes the renamed-field failure visible.

Neither check proves that the values are correct. If the filter returns the wrong value under the correct field name, both the count and identity checks can pass. That requires an additional assertion tied to the value’s expected content or behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use evidence independent of the instrument

A check becomes circular when it uses the instrument’s own summary as the reference for whether that instrument worked. Hirakawa recounts three examples: using a filter’s match count to validate field extraction, a search result to validate a code search, and an API’s comments field to validate a comment counter. In each case, the repair was to bring in a reference the instrument did not generate: a declared record type, a term known to be present, or a second endpoint that enumerates comments rather than merely counting them.

A positive control is useful only if it is independent of the behavior being checked. If the control comes from the same source as the result, it can repeat the same error rather than expose it. Hirakawa puts it simply: “The requirement is independence.”

Independence addresses circularity; it does not establish that every observed value is semantically correct. A separate source can tell you whether the instrument saw what it should have seen, while value-level checks are still needed to test whether what it saw was right.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose an invariant by naming the failure

Before trusting a passing check, ask Hirakawa’s question: “which invariant does this reconcile on, and what failure preserves it”. Then build a concrete failure case and ask, “does this catch the bug”.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • If the failure could rename or omit an item without changing the total, compare identities, not just counts.
  • If the failure could duplicate items, check cardinality or uniqueness as appropriate.
  • If the failure could retain names but corrupt their values, validate the values against independent expectations.
  • Where possible, make the reference evidence independent of the system whose output is being validated.

As Hirakawa writes, “A check only catches failures that break the invariant it reconciles on.” A passing check is evidence about that invariant—not proof that the entire result is correct.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.