Add dedicated event types for organisation role deserialisation#1485
Merged
csrbarber merged 2 commits intoworkos:mainfrom Feb 13, 2026
Merged
Conversation
Contributor
Greptile OverviewGreptile SummaryIntroduced dedicated event types for organization role events to correctly preserve API response fields that were previously dropped during deserialization.
The change addresses the mismatch between Events API and REST API response shapes, where the Events API includes additional fields that were being silently dropped. Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant API as Events API
participant Deserializer as Event Deserializer
participant EventTypes as OrganizationRoleEvent Types
participant RestTypes as OrganizationRole Types (REST API)
Note over API,EventTypes: Event Flow (organization_role.* events)
API->>Deserializer: organization_role.created/updated/deleted
Note over API: Response includes:<br/>organization_id, resource_type_slug,<br/>object: "organization_role"
Deserializer->>EventTypes: deserializeOrganizationRoleEvent()
EventTypes-->>Deserializer: OrganizationRoleEvent with all fields preserved
Note over Deserializer,RestTypes: REST API Flow (unchanged)
Note over RestTypes: Response includes:<br/>id, type,<br/>object: "role"
Note over RestTypes: Uses deserializeOrganizationRole()<br/>for REST endpoints
Last reviewed commit: 0c5cd84 |
The Events API returns a different shape for organisation role event
data compared to the REST API. The event data includes organisation_id
and resource_type_slug fields that are not present in the REST API
response, and uses a different object type ("organization_role" vs
"role").
Previously, the event serialiser reused OrganizationRole /
OrganizationRoleResponse types from the REST API, which caused
organization_id to be silently dropped during deserialisation. This
made it impossible to determine which organisation a role belongs to
when consuming organisation_role.* events.
Introduces OrganizationRoleEvent / OrganizationRoleEventResponse
interfaces and a deserializeOrganizationRoleEvent serialiser that
correctly preserves all fields from the Events API response.
Closes workos#1484
0c5cd84 to
716ce13
Compare
csrbarber
approved these changes
Feb 13, 2026
Contributor
csrbarber
left a comment
There was a problem hiding this comment.
Thank you for this @smorimoto! I've added suggestions to include the event id, along with a variable rename.
Merged
csrbarber
added a commit
that referenced
this pull request
Feb 13, 2026
## Description Includes #1485 ## Documentation Does this require changes to the WorkOS Docs? E.g. the [API Reference](https://workos.com/docs/reference) or code snippets need updates. ``` [ ] Yes ``` If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.
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
OrganizationRoleEvent/OrganizationRoleEventResponseinterfaces that match the actual Events API response shape fororganization_role.*eventsdeserializeOrganizationRoleEventserialiser that correctly preservesorganization_idandresource_type_slugfrom the event dataThe Events API returns a different shape for organisation role data compared to the REST API (e.g.
object: "organization_role"vs"role", includesorganization_idandresource_type_slug). Previously, the sharedOrganizationRole/OrganizationRoleResponsetypes silently dropped these fields during deserialisation.Closes #1484
Test plan
npx tsc --noEmit)npm test)