Backward compatibility

What it is

Backward compatibility means a newer version maintains the behaviour
needed by supported consumers of an earlier version. The scope
depends on the thing being changed. An API can support clients that
were written against the previous contract. A library can preserve
important call signatures and results. A storage format can give new
software a way to read records produced before an upgrade.

Compatibility has several layers. A field can retain its wire type
and still change its meaning. A number that represented seconds
could begin representing milliseconds. A query that always returned
a stable order could shift to an order that affects the client's
pagination. Choose the behaviour that callers can rely on and check
it through the actual boundary. A durable record of what is
supported helps reviewers decide whether a change is compatible.

State the direction each check covers. A consumer built before a
change might have to run with a newer service. During a release, the
newer consumer might also call an older service. The second
situation is a separate requirement that depends on the deployment
sequence. Testing the supported combinations gives the word
compatible a concrete meaning for the product.

Why it matters

Clients can outlive the release that introduced them. A mobile
application might remain installed for months. A partner might
refresh its generated client only after a scheduled review. Stored
records can be years old when a service needs to replay them.
Changes that look local in the source can affect users who have
never installed the latest software.

Backward-compatible steps help during gradual releases. A service
can accept both an old request form and a new one while its
consumers move. The new representation can become the default once
the supported clients understand it. Keep the overlap deliberate.
Test how readers and writers behave during it and give the older
behaviour a clear support policy.

A compatibility rule also lets a team choose what a release
promises. A published client library can list which versions of the
API it supports. An internal service can set a shorter overlap when
every consumer is controlled by the same organisation. Both
arrangements require evidence. An assumption about who can deploy
quickly is weaker than a record of the versions still used on the
real route.

What it looks like in practice

Imagine an order API that adds a delivery estimate. Keep an older
client binary or a fixture that uses its original deserializer. Send
it a normal response from the new service. Confirm that the old
behaviour remains useful and that a client that already understands
the new field handles it as intended. Also test the case where the
field is missing. A client that fails without it may need a release
ordering decision.

Consider a coded status or enumeration as a separate case. A
consumer might handle every previously known status in a closed
list. An extra value can require a clear fallback or a new version
even if the wire encoding permits it. Test the old client with the
new value and verify what a user sees. This catches compatibility
problems that are invisible when only the newest generated types are
exercised.

Engineer's typed API migration case study describes migrating
handlers gradually, publishing their descriptions and checking
agreement between the registered routes and the OpenAPI output. That
offers a concrete place to start for a reader working on an API. A
compatibility check can add fixtures for the older clients' requests
and interpretations, so the new service shows what its published
contract means across releases.

Record the exact version pairing as part of the result. A test can
use a previously published client with the candidate server and a
persisted record produced by the older writer. After a change, read
back what the fixture stored and compare the relevant fields. These
tests support an explanation of what changes and how the product
handles its existing consumers.

Where it goes wrong

A change can preserve types while changing a business rule. An
omitted field might gain a different default. A success response can
be sent before an operation becomes durable when older clients
expected it to be complete. Include examples that specify meaning,
timing and failure behaviour. A reviewer needs those details to tell
whether the product's compatibility promise still holds.

Look for assumptions outside the obvious client. A dashboard can
read stored values directly and a batch job can use a response body
to decide which retries are safe. An interface document may describe
only the route, so inventory both the formal consumers and the
integrations actually observed. Run at least one existing caller
through a full operation, from sending the first request to
observing its stored outcome. The sequence can reveal a change in
state or timing even when each individual response still looks
valid.

A team may also infer compatibility from a version number. Semantic
versioning gives a naming policy for releases with a public API, but
a number does not test the relevant behaviours. Pair an agreed
version policy with fixtures from supported versions. Add a
transition path when data can remain in storage after the software
that created it is gone. Keep the commitment discoverable where
callers decide whether to upgrade.

Finally, give a compatibility promise an intentional end. If a
representation is no longer needed, make its retirement visible,
confirm its remaining use and test the supported replacement. If an
important consumer cannot follow the scheduled change, the team can
choose a longer overlap or a new interface version. A good decision
leaves a support window people understand and concrete evidence
about what the current product can still read and serve.

Further reading

  * Google AIP-180 on backwards compatibility. Explains wire, source
and semantic compatibility for APIs.

  * Protocol Buffers guidance for updating message types. Describes
changes and their effects on encoded messages.

  * Semantic Versioning 2.0.0. Defines version-number conventions
around a declared public API.

hThis page on the web	URL:https://engineer.company/glossary/backward-compatibility/	engineer.company	70
