Add custom_attributes field to OrganizationMembership#419
Merged
gjtorikian merged 4 commits intomainfrom Feb 2, 2026
Merged
Conversation
- Add :idp_attributes to attr_accessor - Initialize @idp_attributes with default empty hash - Include idp_attributes in to_json output This change adds support for IDP custom attributes on organization memberships, which are sourced from the identity provider and stored as customAttributes in the API. Related to workos/workos PR #50470 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Greptile OverviewGreptile SummaryAdds This fits the existing pattern in this codebase where API resource wrappers parse JSON into instance variables and re-expose them through Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant OrgMembership as WorkOS::OrganizationMembership
Client->>OrgMembership: initialize(json)
OrgMembership->>OrgMembership: JSON.parse(json, symbolize_names: true)
OrgMembership->>OrgMembership: @idp_attributes = hash[:idp_attributes]
Client->>OrgMembership: to_json
OrgMembership-->>Client: { ..., idp_attributes: idp_attributes, ... }
|
| @status = hash[:status] | ||
| @role = hash[:role] | ||
| @roles = hash[:roles] | ||
| @idp_attributes = hash[:idp_attributes] || {} |
There was a problem hiding this comment.
Inconsistent default value behavior compared to other fields in this class. Other optional fields like role, roles, etc. are set to nil when not present, but idp_attributes defaults to {}. This could cause unexpected behavior when checking for presence.
Suggested change
| @idp_attributes = hash[:idp_attributes] || {} | |
| @idp_attributes = hash[:idp_attributes] |
Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/workos/organization_membership.rb
Line: 21:21
Comment:
Inconsistent default value behavior compared to other fields in this class. Other optional fields like `role`, `roles`, etc. are set to `nil` when not present, but `idp_attributes` defaults to `{}`. This could cause unexpected behavior when checking for presence.
```suggestion
@idp_attributes = hash[:idp_attributes]
```
How can I resolve this? If you propose a fix, please make it concise.…tion API guarantees idp_attributes is always present, so no default needed.
Contributor
Author
gjtorikian
approved these changes
Feb 2, 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.
Summary
Adds
custom_attributesfield toOrganizationMembershipmodel to expose custom attributes from identity providers.Changes
custom_attributesfield to OrganizationMembership type/model{}API Field Details
The field will be present in:
JSON field name:
custom_attributes(snake_case)