Skip to content

fix(events): Add resourceTypeSlug to RoleEvent deserialization#1638

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782159722-add-resource-type-slug-to-role-event
Open

fix(events): Add resourceTypeSlug to RoleEvent deserialization#1638
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782159722-add-resource-type-slug-to-role-event

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Description

The RoleEvent and RoleEventResponse interfaces were missing the resourceTypeSlug / resource_type_slug field, and the deserializer was hardcoding object: 'role' instead of reading it from the response. This caused resource_type_slug to be silently dropped during event deserialization for role.created, role.updated, and role.deleted events.

Changes:

  • RoleEventResponse: add resource_type_slug: string
  • RoleEvent: add resourceTypeSlug: string
  • deserializeRoleEvent: map resource_type_slugresourceTypeSlug and use role.object instead of hardcoded 'role'

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

Link to Devin session: https://app.devin.ai/sessions/8f83ad1ad4f94e1a9705a4c028f35786
Requested by: @csrbarber

@devin-ai-integration devin-ai-integration Bot requested review from a team as code owners June 22, 2026 20:22
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author
Original prompt from heather

SYSTEM:
=== BEGIN THREAD HISTORY (in #dse-collab) ===
Heather Faerber (U08CUNLUBT9): Got some feedback from a customer:
> In the WorkOS node SDK, I noticed there is this missing resourceTypeSlug field in the RoleEvent type. As a result the field gets dropped silently.

<most_recent_message>
Heather Faerber (U08CUNLUBT9): @Devin can you take a look?
</most_recent_message>
=== END THREAD HISTORY ===

Thread URL: https://work-os.slack.com/archives/C08DTU7CXMF/p1782159595345779?thread_ts=1782159595.345779&amp;cid=C08DTU7CXMF

The latest message is the one right above that tagged you. The <most_recent_message> is the message that you should use to guide your goals + task for this session, and you should use the rest of the slack thread as context.

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot changed the title Add resourceTypeSlug to RoleEvent type fix: Add resourceTypeSlug to RoleEvent type Jun 22, 2026
@greptile-apps

greptile-apps Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds the missing resourceTypeSlug / resource_type_slug field to RoleEvent and RoleEventResponse, and fixes the serializer to read object from the response rather than hardcoding 'role'.

  • role.interface.ts: Adds resource_type_slug: string to RoleEventResponse and resourceTypeSlug: string to RoleEvent, bringing them into parity with the already-complete OrganizationRoleEvent / OrganizationRoleEventResponse interfaces.
  • role.serializer.ts: Maps role.resource_type_slug → resourceTypeSlug and uses role.object instead of the hardcoded string literal, consistent with all other serializers in the codebase.

Confidence Score: 5/5

Safe to merge — the fix is additive and consistent with the existing OrganizationRoleEvent pattern already in the codebase.

Both changed files apply a focused, well-scoped addition. The new field and its mapping exactly mirror the OrganizationRoleEvent / OrganizationRoleEventResponse pair that has been working correctly. No existing fields are removed or renamed, and the TypeScript type system ensures the mapping is structurally sound.

No files require special attention.

Important Files Changed

Filename Overview
src/roles/interfaces/role.interface.ts Adds missing resource_type_slug / resourceTypeSlug field to RoleEventResponse and RoleEvent interfaces, matching the pattern already established by OrganizationRoleEventResponse / OrganizationRoleEvent
src/user-management/serializers/role.serializer.ts Maps the new resource_type_slug field to resourceTypeSlug and reads object from the response instead of hardcoding it, consistent with all other role serializers

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant API as WorkOS API
    participant ES as event.serializer.ts
    participant RS as role.serializer.ts
    participant App as Application

    API->>ES: "EventResponse { event: role.created, data: RoleEventResponse }"
    Note over ES: Matches case role.created
    ES->>RS: deserializeRoleEvent(event.data)
    Note over RS: Maps resource_type_slug to resourceTypeSlug
    RS-->>ES: "RoleEvent { object, slug, resourceTypeSlug, permissions, ... }"
    ES-->>App: "Event { event: role.created, data: RoleEvent }"
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant API as WorkOS API
    participant ES as event.serializer.ts
    participant RS as role.serializer.ts
    participant App as Application

    API->>ES: "EventResponse { event: role.created, data: RoleEventResponse }"
    Note over ES: Matches case role.created
    ES->>RS: deserializeRoleEvent(event.data)
    Note over RS: Maps resource_type_slug to resourceTypeSlug
    RS-->>ES: "RoleEvent { object, slug, resourceTypeSlug, permissions, ... }"
    ES-->>App: "Event { event: role.created, data: RoleEvent }"
Loading

Reviews (2): Last reviewed commit: "fix(events): Add resourceTypeSlug to Rol..." | Re-trigger Greptile

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration devin-ai-integration Bot force-pushed the devin/1782159722-add-resource-type-slug-to-role-event branch from f43c109 to 54d636b Compare June 23, 2026 13:20
@devin-ai-integration devin-ai-integration Bot changed the title fix: Add resourceTypeSlug to RoleEvent type fix(events): Add resourceTypeSlug to RoleEvent deserialization Jun 23, 2026
@csrbarber csrbarber requested a review from gjtorikian June 23, 2026 13:22
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.

1 participant