-
Notifications
You must be signed in to change notification settings - Fork 34
Add custom_attributes field to OrganizationMembership #419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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, ... }
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
| @status = hash[:status] | ||
| @role = hash[:role] | ||
| @roles = hash[:roles] | ||
| @idp_attributes = hash[:idp_attributes] || {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| @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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, no comments
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)