What is a tolerant reader?
The Tolerant Reader pattern is an integration design approach where a client consuming data is built to handle potential changes—such as added fields or minor structure modifications—gracefully. This pattern promotes forward compatibility, reducing the need for immediate updates whenever the data or service evolves.Real-world scenario
Consider a request toGET /organizations/{organization_id}
. Initially, the response might be:
doingBusinessAs
and address
may be added:
Implementing a tolerant reader
Below is an example Python code snippet that processes additional fields gracefully, accounting for changes in the payload.get
methods are used to safely access values. This allows for flexibility if new fields, such as phoneNumber
, are introduced, as the code remains functional even if a field is absent.