Skip to content
Robustness Principle — Explained with Examples

Robustness Principle — Explained with Examples

DodaTech Updated Jun 15, 2026 2 min read

The Robustness Principle (Postel’s Law) advises being conservative in what you send and liberal in what you accept from others.

Robustness Principle, also known as Postel’s Law, was formulated by Jon Postel in the specification of TCP (RFC 793). It states: “Be conservative in what you do, be liberal in what you accept from others.”

Why It Matters

In networked systems and APIs, not all clients follow the specification perfectly. A strict receiver would reject valid-but-non-conformant messages, breaking interoperability. By being liberal in accepting input while strict in producing output, systems maximize compatibility and resilience.

Real-World Analogy

A post office: when sending mail, you must use the correct address format, stamp, and envelope (conservative). When receiving, postal workers tolerate variations — handwritten addresses, slightly bent envelopes, missing zip codes (liberal). If they rejected every imperfect envelope, most mail would never arrive.

Example: Postel’s Law in API Design

# Being liberal in what you accept
def parse_date(date_input):
    """Accept multiple date formats liberal"""
    from datetime import datetime

    formats = [
        "%Y-%m-%d",           # 2024-06-15
        "%m/%d/%Y",           # 06/15/2024
        "%d-%m-%Y",           # 15-06-2024
        "%B %d, %Y",          # June 15, 2024
        "%d %B %Y",           # 15 June 2024
    ]

    for fmt in formats:
        try:
            return datetime.strptime(date_input, fmt)
        except ValueError:
            continue

    raise ValueError(f"Could not parse date: {date_input}")

# Conservative in what you send
def format_response(data):
    """Always produce the same canonical format"""
    return {
        "status": "ok",
        "data": data,
        "version": "1.0",
        "timestamp": datetime.utcnow().isoformat() + "Z"
    }

# Usage
print(parse_date("06/15/2024"))  # Accepts US format
print(parse_date("2024-06-15"))  # Accepts ISO format
print(format_response({"message": "hello"}))
# Always returns consistent structure

Related Terms

Defensive Programming, Fail Fast, Principle of Least Astonishment

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro