We removed one unused field from an API response and crashed three old app versions
A cleanup release dropped a field the web app no longer used. Android versions from a year ago still decoded it as required and crashed on launch. Why mobile makes every API change public, and the compatibility rules, deprecation headers and version policy we use now.
Crash reports for our Android app jumped from a few dozen a day to over four thousand in the hour after a backend deploy. Every crash was on launch, and every one came from app versions 5.8 to 6.1, released between nine and fifteen months earlier. Current versions were fine. iOS was fine.
The crash reporter grouped them into one issue:
Fatal Exception: kotlinx.serialization.MissingFieldException
Field 'legacy_tier' is required for type with serial name 'com.example.app.api.Account',
but it was missing at path: $.account
at com.example.app.api.AccountService.fetchProfile(AccountService.kt:41)
at com.example.app.startup.SessionLoader.load(SessionLoader.kt:27)
legacy_tier was a field on GET /v1/me that described a pricing tier we retired in 2025. The deploy
included a cleanup pull request titled "Remove unused legacy_tier from account response". The web app
did not read it. The current Android and iOS apps did not read it. We had checked that before merging.
What we had not checked was what older apps did with it.
Why only old Android versions
In app versions up to 6.1, the Android team's Account model declared the field without a default:
@Serializable
data class Account(
val id: String,
val name: String,
@SerialName("legacy_tier") val legacyTier: String,
val plan: Plan,
)
With kotlinx.serialization, a property without a default value is required. When the key is missing, the
decoder throws MissingFieldException. The app called /v1/me during startup and had no fallback, so the
exception reached the top and the app closed.
Version 6.2 had dropped the property when the pricing UI changed. iOS used Codable with the property
declared optional from the start, so a missing key decoded as nil.
How many people
Our analytics showed about 7 percent of daily active Android users still on 5.8 to 6.1. Many were drivers on company-managed devices where updates are controlled by an IT department, not by the user.
We rolled back the backend deploy within 40 minutes. The crashes stopped immediately, because the field came back.
A mobile app is a client you cannot redeploy
A web frontend and its API usually ship together: if you remove a field, you also deploy the frontend that stopped reading it, and within minutes nobody runs the old code. A mobile app is different. Every version you have ever released is still running somewhere until its users update, and some never will.
That makes the API contract with mobile clients effectively public. A change is safe only if every version still in use handles it, not just the current one.
Which changes break clients
| Change | Safe for existing clients? |
|---|---|
| Add a new optional response field | Usually yes, if clients ignore unknown keys |
| Add a new optional request parameter | Yes |
| Remove a response field | No, if any client requires it |
| Rename a field | No, it is a removal plus an addition |
Change a field's type ("12" to 12) |
No |
| Add a new enum value to a response | Often no, if clients use exhaustive switches |
| Make an optional request field required | No |
Even "add a field" depends on the client. kotlinx.serialization by default fails on unknown keys unless
ignoreUnknownKeys = true is set. Our Android app had that setting, which is why additions had never
caused trouble and why we had come to think of the API as easy to change.
What our process was missing
- No record of which fields each client version reads.
- No deprecation step: the field went from present to gone in one deploy.
- No minimum supported version, so there was no agreed point at which old versions could be dropped.
Environment
| Item | Value |
|---|---|
| API | REST, JSON, /v1 since 2022 |
| Android | Kotlin, kotlinx.serialization; affected versions 5.8 to 6.1 |
| iOS | Swift, Codable with optional properties |
| Share of DAU on affected versions | about 7% of Android |
1. The immediate fix: put the field back
After the rollback we restored legacy_tier permanently for /v1, returning a fixed value
"standard". That is a few bytes per response, and it keeps every old version working. The field is now
documented as deprecated.
2. Rules for changing a response
We wrote down the contract and put it in the API style guide:
- Additive only within a version. New fields and endpoints are fine. Removing, renaming or changing a type requires a deprecation period, and for mobile-facing fields usually a new version.
- Never add a value to an enum clients switch on without a documented "unknown" fallback in every client. Clients must handle unknown enum values; the server must not rely on them doing so for old versions.
- Deprecate before removing, with headers and a date.
3. Deprecation and Sunset headers
Fields cannot carry headers, but endpoints can. When an endpoint or version is being retired we send
the Sunset header from RFC 8594 and the Deprecation header from RFC 9745:
HTTP/1.1 200 OK
Deprecation: @1767225600
Sunset: Wed, 30 Jun 2027 00:00:00 GMT
Link: <https://developer.example.com/changes/v1-me>; rel="deprecation"
Deprecation takes a structured-field date (seconds since the epoch, prefixed with @) saying when the
resource became deprecated. Sunset says when it may stop working. Link with rel="deprecation" points
to human-readable details. Our own clients log a warning in debug builds when they see Deprecation, so
developers notice before users do.
For individual fields, the OpenAPI document marks them deprecated: true, and a changelog entry names the
version in which they will disappear.
4. A minimum supported version
The real long-term fix is being able to say "versions older than X are no longer supported". We added:
- An
X-App-Versionrequest header sent by both mobile apps. - A config value
min_supported_versionper platform. Requests from older versions receive426 Upgrade Requiredwith a JSON body the app displays as an "Update required" screen. - A policy: we support app versions released in the last 12 months, and we announce a raise of the minimum 30 days in advance in the app.
The forced-update screen itself was the hardest part. It had to ship in a release and reach most users before we could rely on it. Versions without it will crash or misbehave on any future breaking change, so those are exactly the versions we keep fully compatible until their usage falls below 0.5 percent.
5. Know who reads what
We added per-version field usage tracking on the client side: each app version declares, at build time, the response fields its models require. The list is uploaded to an internal registry. Before removing a field, a script checks the registry against current version usage:
api-compat check --endpoint "GET /v1/me" --remove account.legacy_tier
account.legacy_tier is required by:
android 5.8.0 .. 6.1.3 (6.8% of android DAU, last 7 days)
Removal blocked. Deprecate and wait until usage < 0.5%, or raise min_supported_version.
1. A compatibility test suite with recorded client fixtures. For every supported app version we keep the request and response pairs its integration tests use. CI replays them against the current API and decodes responses with that version's models (pulled from the tagged release), so a removed required field fails the build:
FAIL android-6.0.4 GET /v1/me: MissingFieldException: Field 'legacy_tier' is required
2. OpenAPI diff in CI. A breaking-change detector compares the OpenAPI document with the last released one and fails on removed fields, type changes and newly required parameters, unless the pull request is labelled with an approved breaking-change ticket.
3. Client hardening. Android now sets defaults or nullable types for every response property, and
ignoreUnknownKeys = true remains. Both apps map unknown enum values to an Unknown case. These changes
help future versions; they do nothing for versions already installed, which is why the server rules matter
more.
4. Security implications. The minimum-version mechanism doubles as a security tool: when an app
version has a vulnerability, we can block it instead of hoping users update. We made sure 426 responses
contain no account data and that the check runs before authentication, so the update screen works even
when the old app's login flow is incompatible.
Takeaways
- Every mobile version you have released is a client of your API until it is gone. Treat responses as a public contract.
- Within a version, change APIs additively. Removing, renaming and retyping are breaking changes.
- Deprecate first, with
DeprecationandSunsetheaders and a date, then remove. - Have a minimum supported version and a forced-update path before you need one.
References: RFC 8594, The Sunset HTTP Header Field, RFC 9745, The Deprecation HTTP Response Header Field, kotlinx.serialization JSON configuration, OpenAPI Specification.
Add a label
Embed this post
<iframe src="https://hibug.me/removed-field-broke-old-mobile-clients" width="700" height="420" frameborder="0" loading="lazy"></iframe>
I build and maintain public and partner APIs, currently for a logistics platform with web, mobile and third-party clients all calling the same endpoints. Before that I worked on identity: login, sessions, OAuth integrations and the long tail of edge cases they create. The bugs I care about sit at the contract between client and server. A PUT that wiped fields the client never sent, a cache that served one user's page to another, a field removal that broke app versions still in the wild, a refresh flow that logged people out when two tabs raced. None of these show up in a happy-path demo. My posts walk through how each one surfaced, what the HTTP or auth spec actually says, the fix we shipped and the tests we added so the next change to the API does not repeat it.
Comments
0No comments yet. Be the first to comment!
Sign In to post a comment.