Skip to content

Conversation

@ajworkos
Copy link
Contributor

@ajworkos ajworkos commented Feb 1, 2026

Summary

Adds custom_attributes field to OrganizationMembership model to expose custom attributes from identity providers.

Changes

  • Added custom_attributes field to OrganizationMembership type/model
  • Field type: Record/Map/Dictionary of string keys to any values
  • Always present, defaults to empty object {}
  • Updated fixtures and tests

API Field Details

The field will be present in:

  • REST API responses
  • Webhook events
  • Events API responses

JSON field name: custom_attributes (snake_case)

- 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>
@ajworkos ajworkos requested a review from a team as a code owner February 1, 2026 16:18
@ajworkos ajworkos requested review from mthadley and removed request for a team February 1, 2026 16:18
@greptile-apps
Copy link

greptile-apps bot commented Feb 1, 2026

Greptile Overview

Greptile Summary

Adds idp_attributes to WorkOS::OrganizationMembership so custom Identity Provider attributes are exposed on the model and included in serialization via to_json.

This fits the existing pattern in this codebase where API resource wrappers parse JSON into instance variables and re-expose them through attr_accessor plus a hash-style to_json representation.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • The change is a straightforward addition of a new parsed attribute and its inclusion in serialization, matching existing resource-wrapper patterns, with no behavioral changes outside exposing the new field.
  • No files require special attention

Important Files Changed

Filename Overview
lib/workos/organization_membership.rb Adds OrganizationMembership#idp_attributes attribute, sets it from parsed JSON, and includes it in to_json.

Sequence Diagram

sequenceDiagram
  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, ... }
Loading

Copy link

@greptile-apps greptile-apps bot left a 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

Edit Code Review Agent Settings | Greptile

@status = hash[:status]
@role = hash[:role]
@roles = hash[:roles]
@idp_attributes = hash[:idp_attributes] || {}
Copy link

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.

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.
@ajworkos
Copy link
Contributor Author

ajworkos commented Feb 1, 2026

@greptileai

Copy link

@greptile-apps greptile-apps bot left a 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

Edit Code Review Agent Settings | Greptile

@ajworkos ajworkos changed the title Add idp_attributes field to OrganizationMembership Add custom_attributes field to OrganizationMembership Feb 2, 2026
@gjtorikian gjtorikian merged commit aff3593 into main Feb 2, 2026
4 checks passed
@gjtorikian gjtorikian deleted the feature/add-idp-attributes-to-org-membership branch February 2, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants