Great work!

XP to next level

BugEater

Silent Corruption vs Validation: Two Failure Modes for Invalid Dates

Learning Objectives

By the end of this lesson you will be able to:

  • Identify the two failure modes when a system receives an invalid date
  • Explain why silent corruption is more dangerous than a validation error
  • Describe how to detect silent date corruption using black-box testing techniques
  • Distinguish between HTTP 422 and HTTP 200 in the context of data integrity

The Two Failure Modes

When an application receives an invalid date — one that does not exist on a real calendar or violates the expected format — exactly two outcomes are possible:

Mode A — Validation Error (Rejection): The system detects the invalid date, refuses to process it, and returns an error to the caller. The date is never written to the database. The response typically carries a 4xx HTTP status code (400 Bad Request or 422 Unprocessable Entity) and an error message describing the problem.

Mode B — Silent Corruption (Acceptance with wrong data): The system accepts the invalid date, converts it to some internally valid value through lenient parsing or silent truncation, and stores that value in the database. The response is HTTP 200 OK. No error is signaled. The stored value differs from what the caller submitted.

Which Mode Is More Dangerous?

Mode B — silent corruption — is significantly more dangerous for data integrity than Mode A.

When a system returns a validation error (Mode A), the outcome is transparent: the caller knows the submission failed, can inform the user, and can correct the input before retrying. Nothing is written to the database, so no data is corrupted. The system behaves consistently with the principle that incorrect input should be rejected before it causes harm.

When a system silently corrupts data (Mode B), none of that transparency exists:

  • The caller receives a success response and assumes the data was stored correctly.
  • The user is not informed that anything went wrong.
  • The database contains a value that is different from what was submitted and intended.
  • Downstream systems that read the corrupted date will make decisions based on wrong information.
  • The corruption may go undetected for days, weeks, or months — until a downstream failure surfaces.

A classic example: a user books a hotel stay for 2024-02-31. The system silently coerces this to 2024-03-02 and stores that date. The user's booking confirmation shows the correct (as-entered) date from the frontend cache, while the hotel's reservation system has March 2. The discrepancy surfaces only at check-in, causing a significant user experience failure that is difficult to trace back to a date parsing bug.

How to Detect Silent Corruption in Black-Box Tests

Since Mode B produces no error signal, you cannot detect it just by looking at the HTTP status code. The detection strategy requires a write-then-read cycle:

  1. Write: Submit an invalid date via POST or PUT — for example, 2024-02-30, 2024-13-01, or 04/05/2024 when ISO format is expected.
  2. Verify the status code: If the response is 4xx, you are in Mode A (correct behavior). Stop here.
  3. Read back: If the response is 200 OK, immediately perform a GET request for the same resource.
  4. Compare: Extract the date field from the GET response and compare it to what you submitted.
    • If they match: the system accepted and stored the invalid value as-is (still a bug — it should have rejected it, but at least not corrupted).
    • If they differ: you have confirmed Mode B silent corruption. Document both the submitted value and the stored value, compute the difference, and file a defect.

This write-then-read pattern is the fundamental technique for detecting any form of silent data corruption in black-box testing — it applies equally to date fields, numeric fields with overflow, and string fields with encoding issues.

Why HTTP 422 Is Better Than HTTP 200 With Wrong Data

HTTP 422 Unprocessable Entity is the semantically correct response for an invalid date. It signals that the request was syntactically well-formed (valid HTTP, valid JSON) but contained content that the server cannot process because it fails semantic validation — the date does not exist on a calendar.

HTTP 200 OK with wrong data stored is a lie. The status code promises success, but the outcome is failure. This violates the contract between the server and the client.

From a tester's perspective:

  • HTTP 422 on 2024-02-31 → correct behavior, write a positive test case confirming it.
  • HTTP 400 on 2024-02-31 → acceptable (slightly wrong semantics, but the rejection is correct).
  • HTTP 200 on 2024-02-31 with 2024-03-02 stored → defect, severity high, data integrity impact.
  • HTTP 200 on 2024-02-31 with 2024-02-31 stored → defect, severity medium (accepted invalid date, but no coercion — the integrity of downstream reads is unknown).

Designing a Systematic Corruption Test Suite

For any date-accepting endpoint, run these four checks:

Input Expected Failure to detect
Non-existent day: 2024-02-31 422 If 200, do read-back
Non-existent month: 2024-13-01 422 If 200, do read-back
Wrong format: 05/04/2024 (vs ISO) 422 If 200, do read-back
Non-leap day: 2023-02-29 422 If 200, do read-back

Any endpoint that passes all four returning 422 has strict validation. Any endpoint that passes any returning 200 needs read-back verification for silent corruption.

Quiz

Which failure mode is more dangerous for data integrity when a system receives an invalid date?

How do you detect silent date corruption in a black-box test?

What HTTP status code correctly indicates that a submitted date failed semantic validation?

Why is silent corruption harder to detect than a parsing exception?