Skip to content

Robustness

Every API service or consumer implementation MUST follow the "Robustness principle":

Be conservative in what you send, be liberal in what you accept

– John Postel

Acceptable means of compliance

  • When sending data to a service, stick to the contract/documentation when it comes to the format or specification. Do data transformation if necessary.
  • When processing data that is sent from a client, be only strict if there is a probability of miscomputation. Don't guess or assume.

Example:

Given your API expects a language code following BCP 47, i.e. two lcase letters, a hyphen, and to ucase letters (e.g. de-CH).

One would send these case sensitively, but the API SHOULD accept a mixed case if given. However the API SHOULD quit with an error if the language/country combination is invalid or not supported altogether.