Skip to content

Conversation

@rarevalo13
Copy link
Contributor

Description

Session.revoke event was missing, this PR adds support for it in the Python SDK

Local Test using Ipython:

In [6]: client.events.list_events(events=["session.revoked"]).data
Out[6]:
[SessionRevokedEvent(id='event_01KAE1KWW6ME1P6MMQZJ6FP7RR', object='event', data=SessionRevokedPayload(object='session', id='<SESSION ID>', impersonator=None, ip_address='73.195.86.87', organization_id=None, user_agent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36', user_id='<USER ID>', created_at='2025-11-19T12:31:46.359Z', updated_at='2025-11-19T12:32:17.781Z'), created_at='2025-11-19T12:32:17.798Z', event='session.revoked')

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.

@rarevalo13 rarevalo13 requested a review from a team as a code owner December 15, 2025 13:38
@rarevalo13 rarevalo13 requested a review from mattgd December 15, 2025 13:38
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 15, 2025

Greptile Overview

Greptile Summary

Adds support for session.revoked event type by creating SessionRevokedPayload and SessionRevokedEvent classes following the established patterns in the SDK.

Changes:

  • Renamed session_created_payload.py to session_payload.py to consolidate session-related payloads
  • Added SessionRevokedPayload with identical structure to SessionCreatedPayload
  • Added "session.revoked" to EventType literal union
  • Created SessionRevokedEvent and SessionRevokedWebhook classes
  • Updated all relevant imports and type unions

Minor issues:

  • Import formatting inconsistent (import( should be import ( with space)
  • Missing newline at end of session_payload.py

Confidence Score: 4/5

  • Safe to merge after fixing minor formatting issues
  • Implementation follows SDK patterns correctly with proper type definitions and union updates. Only style/formatting issues present - no logical errors. Author tested successfully with IPython.
  • All files have minor formatting issues with import statements and EOF newline that should be cleaned up before merge

Important Files Changed

File Analysis

Filename Score Overview
workos/types/events/session_payload.py 4/5 Renamed from session_created_payload.py and added SessionRevokedPayload with identical structure to SessionCreatedPayload. Missing newline at EOF.
workos/types/events/event.py 4/5 Added SessionRevokedEvent class and updated imports. Import formatting inconsistent with codebase style.
workos/types/events/event_model.py 4/5 Added SessionRevokedPayload to EventPayload TypeVar. Import formatting inconsistent with codebase style.
workos/types/webhooks/webhook.py 4/5 Added SessionRevokedWebhook class and updated imports. Import formatting inconsistent with codebase style.

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant SDK as WorkOS Python SDK
    participant API as WorkOS API
    participant Webhook as Webhook Handler

    Note over App,Webhook: Session Revoked Event Flow

    rect rgb(240, 240, 255)
        Note right of API: Event occurs in WorkOS
        API->>API: Session revoked
        API->>Webhook: POST session.revoked event
        Webhook->>SDK: Parse webhook payload
        SDK->>SDK: Deserialize to SessionRevokedWebhook
        SDK->>SDK: Extract SessionRevokedPayload
        Webhook-->>App: SessionRevokedEvent object
    end

    rect rgb(255, 240, 240)
        Note right of App: Polling for events
        App->>SDK: client.events.list_events(events=["session.revoked"])
        SDK->>API: GET /events?events=session.revoked
        API-->>SDK: Event data
        SDK->>SDK: Deserialize to SessionRevokedEvent
        SDK-->>App: List[SessionRevokedEvent]
    end

    Note over App,Webhook: SessionRevokedPayload contains:<br/>id, user_id, ip_address, user_agent,<br/>organization_id, impersonator, timestamps
Loading

Copy link
Contributor

@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.

5 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

user_agent: Optional[str] = None
user_id: str
created_at: str
updated_at: str
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: missing newline at end of file

Suggested change
updated_at: str
updated_at: str
Prompt To Fix With AI
This is a comment left during a code review.
Path: workos/types/events/session_payload.py
Line: 27:27

Comment:
**style:** missing newline at end of file

```suggestion
    updated_at: str

```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 39 to 42
from workos.types.events.session_payload import(
SessionCreatedPayload,
SessionRevokedPayload
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: missing space before ( in import statement - should be import ( not import(

Suggested change
from workos.types.events.session_payload import(
SessionCreatedPayload,
SessionRevokedPayload
)
from workos.types.events.session_payload import (
SessionCreatedPayload,
SessionRevokedPayload
)
Prompt To Fix With AI
This is a comment left during a code review.
Path: workos/types/events/event.py
Line: 39:42

Comment:
**style:** missing space before `(` in import statement - should be `import (` not `import(`

```suggestion
from workos.types.events.session_payload import (
    SessionCreatedPayload,
    SessionRevokedPayload
)
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 39 to 42
from workos.types.events.session_payload import(
SessionCreatedPayload,
SessionRevokedPayload
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: missing space before ( in import statement - should be import ( not import(

Suggested change
from workos.types.events.session_payload import(
SessionCreatedPayload,
SessionRevokedPayload
)
from workos.types.events.session_payload import (
SessionCreatedPayload,
SessionRevokedPayload
)
Prompt To Fix With AI
This is a comment left during a code review.
Path: workos/types/events/event_model.py
Line: 39:42

Comment:
**style:** missing space before `(` in import statement - should be `import (` not `import(`

```suggestion
from workos.types.events.session_payload import (
    SessionCreatedPayload,
    SessionRevokedPayload
)
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 39 to 42
from workos.types.events.session_payload import(
SessionCreatedPayload,
SessionRevokedPayload
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: missing space before ( in import statement - should be import ( not import(

Suggested change
from workos.types.events.session_payload import(
SessionCreatedPayload,
SessionRevokedPayload
)
from workos.types.events.session_payload import (
SessionCreatedPayload,
SessionRevokedPayload
)
Prompt To Fix With AI
This is a comment left during a code review.
Path: workos/types/webhooks/webhook.py
Line: 39:42

Comment:
**style:** missing space before `(` in import statement - should be `import (` not `import(`

```suggestion
from workos.types.events.session_payload import (
    SessionCreatedPayload,
    SessionRevokedPayload
)
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Contributor

@mattgd mattgd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor formatting fixes needed, but this looks good otherwise. Thanks!

@rarevalo13 rarevalo13 merged commit 64a93e8 into main Dec 15, 2025
8 checks passed
@rarevalo13 rarevalo13 deleted the ron-addSupportForSessionRevokeEvents branch December 15, 2025 18:52
rarevalo13 added a commit that referenced this pull request Dec 15, 2025
@rarevalo13 rarevalo13 mentioned this pull request Dec 15, 2025
rarevalo13 added a commit that referenced this pull request Dec 15, 2025
rarevalo13 added a commit that referenced this pull request Dec 16, 2025
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.

3 participants