Skip to content

fix(events): handle domain verification failed#1543

Merged
gjtorikian merged 1 commit intoworkos:mainfrom
noseworthy:handle-domain-verification-failed-events
Apr 7, 2026
Merged

fix(events): handle domain verification failed#1543
gjtorikian merged 1 commit intoworkos:mainfrom
noseworthy:handle-domain-verification-failed-events

Conversation

@noseworthy
Copy link
Copy Markdown
Contributor

Description

The domain verfication failed events have a slightly different schema to other organization domain events. This was causing the data to be parsed incorrectly in the list events api resulting in empty data properties.

I've added the required interfaces, serializers, and deserializers to capture the difference and parse the events successfully. I've also added some unit tests for the serialization.

Documentation

Does this require changes to the WorkOS Docs? E.g. the API 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.

@noseworthy noseworthy requested review from a team as code owners April 6, 2026 15:26
@noseworthy noseworthy requested a review from faroceann April 6, 2026 15:26
@noseworthy
Copy link
Copy Markdown
Contributor Author

Oh crap, I've screwed with the indentation. My editor got a bit aggressive. I'll try to fix that.

@noseworthy noseworthy force-pushed the handle-domain-verification-failed-events branch from b5a4467 to 1a24e70 Compare April 6, 2026 15:29
@noseworthy
Copy link
Copy Markdown
Contributor Author

Okay, should be resolved.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 6, 2026

Greptile Summary

This PR fixes a bug where organization_domain.verification_failed events were being deserialized incorrectly. Unlike other organization domain events (where data is a flat OrganizationDomain), the verification_failed event wraps the domain under an organization_domain key alongside a reason string. The existing code was routing this event through deserializeOrganizationDomain directly, resulting in empty data properties.

  • Adds OrganizationDomainVerificationFailed and OrganizationDomainVerificationFailedResponse interfaces capturing the distinct { reason, organization_domain } schema
  • Adds deserializeOrganizationDomainVerificationFailed (and serializeOrganizationDomainVerificationFailed) that correctly delegates to the existing deserializeOrganizationDomain for the nested domain object
  • Inserts a dedicated case 'organization_domain.verification_failed': in the event switch before the other organization_domain.* cases, preventing any fall-through to the wrong path
  • Updates barrel exports in src/organization-domains/interfaces/index.ts and adds targeted unit tests that exercise the complete deserialization path from raw API response through to the deserialized event

Confidence Score: 5/5

Safe to merge — the fix is well-scoped, follows established codebase patterns exactly, and is validated by a test that directly exercises the previously-broken scenario.

All six changed files contain no P0 or P1 issues. The implementation correctly models the schema difference, the deserialization logic is fully consistent with every other event type in the codebase, and the new test validates the full round-trip from raw API response to deserialized event. The serializeOrganizationDomainVerificationFailed export is consistent with the dual serialize/deserialize pattern used throughout the codebase.

No files require special attention.

Important Files Changed

Filename Overview
src/organization-domains/interfaces/organization-domain-verification-failed.interface.ts New interface correctly models the distinct { reason, organization_domain } schema for verification_failed events
src/organization-domains/serializers/organization-domain-verification-failed.serializer.ts New deserializer/serializer correctly delegates to existing OrganizationDomain serializer for the nested domain object
src/common/interfaces/event.interface.ts New event interfaces added and correctly included in Event and EventResponse union types
src/common/serializers/event.serializer.ts New case for organization_domain.verification_failed correctly placed before other organization_domain.* cases and dispatches to dedicated deserializer
src/organization-domains/interfaces/index.ts Barrel export updated to expose the new verification-failed interface
src/events/events.spec.ts New tests cover both organization_domain.created and organization_domain.verification_failed deserialization, including nested organizationDomain fields

Sequence Diagram

sequenceDiagram
    participant API as WorkOS API
    participant EL as listEvents()
    participant ES as deserializeEvent()
    participant ODVF as deserializeOrganizationDomainVerificationFailed()
    participant OD as deserializeOrganizationDomain()

    API->>EL: EventResponse { event: 'organization_domain.verification_failed',<br/>data: { reason, organization_domain: {...} } }
    EL->>ES: deserializeEvent(eventResponse)
    Note over ES: case 'organization_domain.verification_failed'
    ES->>ODVF: deserializeOrganizationDomainVerificationFailed(data)
    ODVF->>OD: deserializeOrganizationDomain(data.organization_domain)
    OD-->>ODVF: OrganizationDomain (camelCase fields)
    ODVF-->>ES: OrganizationDomainVerificationFailed { reason, organizationDomain }
    ES-->>EL: OrganizationDomainVerificationFailedEvent
    EL-->>API: { data: [OrganizationDomainVerificationFailedEvent] }
Loading

Greploops — Automatically fix all review issues by running /greploops in Claude Code. It iterates: fix, push, re-review, repeat until 5/5 confidence.
Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal.

Reviews (2): Last reviewed commit: "fix(events): handle domain verification ..." | Re-trigger Greptile

The domain verfication failed events have a slightly different schema to
other organization domain events. This was causing the data to be parsed
incorrectly in the list events api resulting in empty `data` properties.

I've added the required interfaces, serializers, and deserializers to
capture the difference and parse the events successfully. I've also
added some unit tests for the serialization.
@noseworthy noseworthy force-pushed the handle-domain-verification-failed-events branch from 1a24e70 to 70dfa4e Compare April 7, 2026 13:39
@gjtorikian
Copy link
Copy Markdown
Contributor

looks great, thank you!

@gjtorikian gjtorikian merged commit 0f3f1ce into workos:main Apr 7, 2026
7 checks passed
@noseworthy noseworthy deleted the handle-domain-verification-failed-events branch April 7, 2026 16:42
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