WIP: Tolerate Unknown Fields in Responses#1425
Open
genematx wants to merge 2 commits into
Open
Conversation
genematx
force-pushed
the
tolerate-unknown-server-fields
branch
2 times, most recently
from
July 8, 2026 18:47
20d8537 to
d6bd226
Compare
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
force-pushed
the
tolerate-unknown-server-fields
branch
from
July 8, 2026 19:03
d6bd226 to
87cec1d
Compare
genematx
marked this pull request as ready for review
July 8, 2026 19:05
danielballan
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 the ticket number which this PR closes to the comment section