fix(models): handle missing primary field when deserializing Role (signed re-push of #44) - #45
Merged
Merged
Conversation
… (signed re-push of #44) Fixes a regression introduced in the 0.4.x releases. Applying `#[serde(deserialize_with = "deserialize_optional_lenient_bool")]` to `Role::primary` suppressed serde's implicit handling of omitted `Option<T>` fields, which would otherwise deserialize to `None`. Because the field carried no `#[serde(default)]`, a payload omitting `primary` was rejected with a `missing field` error. Also bumps the crate to 0.4.2 and records the fix in the changelog. Co-authored-by: Travis Prosser <travis.prosser@lastwall.com>
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.
Summary
Signed re-push of @travipross' commit from #44 (that commit carried an S/MIME signature from an internal CA that GitHub reports as
no_user, so it could not satisfy the signed-commits rule onmain), plus an end-to-end regression test, a version bump, and changelog notes.Role::primarygains#[serde(default)]. Applyingdeserialize_withsuppresses serde's implicit handling of omittedOption<T>fields, so without an accompanyingdefaulta payload that simply omitsprimarywas rejected with amissing fielderror rather than deserializing toNone. This regressed 0.3 behaviour during the 0.4.x lenient-bool work.Tests
Carried over from #44:
role_deserialization_with_omitted_primary_key— minimal reproduction isolating the bug toRole.deserialize_optional_lenient_boolinsrc/utils/serde.rs, includingomitted_key_fails_without_serde_default, which pins the reasondefaultis required at the call site.Added here:
deserialize_github_enterprise_user_list, driven by a newsrc/test_data/github_enterprise_user_list_test.jsonfixture. This is the sanitized real GitHub Enterprise SCIM/Usersresponse @travipross supplied in this comment. The first resource carries a role withprimaryabsent ({"value": "enterprise_owner"}), the second an emptyrolesarray. It exercises the failure at theListResponselevel, which is where it actually bit.Both regression tests were confirmed to fail against the unfixed code, with the reported error:
Scope note
Devin flagged that the other multi-valued structs (
Email,PhoneNumber,Im,Photo,Entitlement,X509Certificate) keep a plainOption<bool>and would still reject a stringified"true". Left as-is deliberately, for two reasons:deserialize_withis present, since that is what suppresses serde'sOptiondefault.Role::primaryis the only production use ofdeserialize_within the crate, so there are no other latent instances. PlainOption<bool>fields already default toNonewhen the key is absent.8d5cc19alongsidesrc/test_data/entra_user_creation_test.json(from Microsoft's SCIM validator), where Entra sends a real boolean forprimaryonemailsandphoneNumbersand a string only onroles. Widening it elsewhere has no driving case today.Release
Cargo.toml0.4.1 → 0.4.2 (Cargo.lockis gitignored, matching chore(release): bump crate version to 0.4.1 #42).CHANGELOG.mdgains a 0.4.2Fixedentry.Tagging
v0.4.2after merge triggers publish + release.Verification
cargo fmt --check,cargo clippy --all-targets -- -D warnings, andcargo test(137 unit + 37 doctests) all pass locally.Original authorship is credited via
Co-authored-by. #44 can be closed once this merges.