Fix outdated organization_membership events#560
Merged
Conversation
Default custom_attributes to empty dict and coerce null values from API to empty dict, ensuring type safety without requiring optional fields. Add event test for null custom_attributes deserialization. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Contributor
Greptile SummaryThis PR fixes a deserialization issue where the WorkOS API can return
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant API as WorkOS API
participant SDK as Python SDK
participant Val as field_validator
participant Model as OrganizationMembership
API->>SDK: Event payload with custom_attributes: null
SDK->>Val: _coerce_null_custom_attributes(None)
Val->>Val: None → {}
Val->>Model: Validate with custom_attributes = {}
Model->>SDK: OrganizationMembership(custom_attributes={})
Last reviewed commit: aa575ec |
custom_attributes is never null from the API, only undefined. Remove the field_validator and null test, keep only the default and the missing-field test. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mattgd
commented
Feb 20, 2026
| roles: Optional[Sequence[OrganizationMembershipRole]] = None | ||
| status: LiteralOrUntyped[OrganizationMembershipStatus] | ||
| custom_attributes: Mapping[str, Any] | ||
| custom_attributes: Mapping[str, Any] = {} |
Contributor
Author
There was a problem hiding this comment.
This handles cases for events from before the IdP attributes in AuthKit release where custom_attributes is undefined.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jonatascastro12
approved these changes
Feb 20, 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.
Description
This PR addresses handling of
custom_attributesin organization membership events. The field is now defaulted to an empty dict and undefined values from the API are coerced to empty dicts, maintaining type safety without requiring optional fields.A new event test verifies that organization_membership events with null custom_attributes deserialize correctly.
Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.