Postel's Law 🧽

The law states:

Be conservative in what you do, be liberal in what you accept from others.

It's an approach for building robust systems by having strict input validation but flexible interpretation of outputs.

The Principle

  • Be strict in validating input - reject bad data
  • Be flexible in handling output - accept non-ideal responses

Benefits

  • Improves system stability
  • Interoperability with other systems
  • Failures contained rather than cascading
  • Less prone to crashes and denial of service
⚠️

Note: The goal is not to hide problems but to build robust. In parallel where applicable, reach out to teams to address root causes.

How to Apply It

  • Validate and sanitize all input data thoroughly
  • Handle non-critical failures gracefully
  • Test edge cases for input but not necessarily output
  • Document expectations clearly

Examples

  • Handle malformed user input on web forms
  • Accept non-standard HTTP headers or status codes
  • Fail fast on bad input but retry on recoverable failures

Postel's Law promotes resilient systems through defensive programming techniques.

Sources