Skip to content

WIP: Tolerate Unknown Fields in Responses#1425

Open
genematx wants to merge 2 commits into
bluesky:mainfrom
genematx:tolerate-unknown-server-fields
Open

WIP: Tolerate Unknown Fields in Responses#1425
genematx wants to merge 2 commits into
bluesky:mainfrom
genematx:tolerate-unknown-server-fields

Conversation

@genematx

@genematx genematx commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Tolerate unknown fields on the client side when decoding server JSON into Asset, DataSource, Spec, and structure dataclasses (AwkwardStructure, TableStructure, ContainerStructure). Unknown keys are dropped and logged at DEBUG so a client can talk to a newer server without crashing on fields it does not recognize.

Related Issue: #1426

Checklist

  • Add a Changelog entry
  • Add the ticket number which this PR closes to the comment section

@genematx
genematx force-pushed the tolerate-unknown-server-fields branch 2 times, most recently from 20d8537 to d6bd226 Compare July 8, 2026 18:47
When a client built against an older Tiled release talks to a newer server
that has added a field to a client-side dataclass (Asset, DataSource, Spec,
AwkwardStructure, TableStructure, ContainerStructure, ...), the client
previously crashed with `TypeError: unexpected keyword argument` because
`Structure.from_json`, `DataSource.from_json`, and `Spec(**...)` splatted the
payload directly into the dataclass.

Add a small `filter_known_kwargs` helper in `tiled.structures._compat` that
drops unknown keys and logs them at DEBUG. Wire it into `Structure.from_json`,
`Asset.from_json` (new), `DataSource.from_json`, and `Spec.from_json` (new),
and update the two `Spec(**spec)` call sites in `tiled.client.base` to use
`Spec.from_json`.

The server continues to strip fields for known-broken client versions via
the User-Agent gate, but this makes the client resilient to any future
additions without requiring a server-side back-compat entry.
@genematx
genematx force-pushed the tolerate-unknown-server-fields branch from d6bd226 to 87cec1d Compare July 8, 2026 19:03
@genematx
genematx requested a review from danielballan July 8, 2026 19:05
@genematx
genematx marked this pull request as ready for review July 8, 2026 19:05
@genematx genematx changed the title Tolerate unknown server fields Tolerate Unknown Fields in Responses Jul 8, 2026
@genematx genematx changed the title Tolerate Unknown Fields in Responses WIP: Tolerate Unknown Fields in Responses Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants