A LibraryOptions boolean a client omits is false, where upstream's constructor makes it true #226
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A client that leaves a
LibraryOptionsboolean out getsfalse, where upstream's constructor sets several of them totrue.Both sides
upstream/MediaBrowser.Model/Configuration/LibraryOptions.csinitialises several booleans totruein its constructor,EnablePhotosamong them. A JSON body that omits one keeps the constructor's value.Ours deserialises into the generated DTO (
crates/ephyra-dto/src/generated/models.rs), whose booleans default tofalse. By the time a handler sees the value, a missing field and an explicitfalselook the same.What a client sees
Since #209,
EnablePhotosis honoured. A client that creates or updates a library with aLibraryOptionsobject lackingEnablePhotossilently turns pictures off in a home-video library. The same applies to every other option upstream defaults totrue.Shape of the fix
This belongs at the generator, not in each handler. Where upstream's model has an initialiser, the generated default should match it. Read the initialisers at the pin, carry them into
cargo xtask gen-enums(or whatever generatesmodels.rs), and regenerate. A route test that posts a library without the field and reads the options back is the one that can fail.Found reviewing #209.
Fixed at the generator, and landed on
mainat76f368b8.A new
xtask/src/initializers.rsreads upstream's own C# declarations per schema — both property initialisers and constructor assignments — andgen_dtoemits a serde default for each boolean that starts attrue.models.rsis regenerated, never hand-edited, andcargo xtask gen-dto --checkpasses against the pinned checkout.65 fields across about twenty schemas, including all six
LibraryOptionsbooleans, all seventeen ofUserPolicy, and fields ofServerConfiguration,EncodingOptions,NetworkConfigurationandMediaSourceInfo. Two same-named classes that disagree are a hard error; one declaring none of the schema's booleans is not the model and is skipped, which is what tellsUserConfigurationapart from its mapping class.A route test posts
LibraryOptionswithoutEnablePhotosand asserts pictures stay on.On the policy route, checked while reviewing. The seventeen that changed are exactly the ones upstream's
UserPolicy()sets.IsAdministrator,IsDisabled,EnableContentDeletionand the rest carry no initialiser and still arrivefalse, so a partial body cannot grant administration or deletion. Upstream's exposure is the same, not narrower: its constructor runs, then only the present properties are set, andUpdateUserPolicyapplies the result wholesale. Before this change we were stricter than upstream on a partial body, which was the bug.Scope: non-nullable booleans only, which the module's documentation now says. The generated
Defaultstill yieldsfalsefor these fields, which is filed as #232 along with two latent limits in the reader.