Skip to content

Fix custom attributes to be nullable#558

Closed
blackmad-cradle wants to merge 3 commits intoworkos:mainfrom
blackmad-cradle:fix-custom-attributes-to-be-nullable
Closed

Fix custom attributes to be nullable#558
blackmad-cradle wants to merge 3 commits intoworkos:mainfrom
blackmad-cradle:fix-custom-attributes-to-be-nullable

Conversation

@blackmad-cradle
Copy link
Contributor

Description

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.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 20, 2026

Greptile Summary

This PR makes two related improvements to the type definitions:

  • Made custom_attributes field nullable (Optional) with a default value of None in DirectoryUser and OrganizationMembership classes, aligning with the existing pattern in the Profile class
  • Added AuthenticationSsoData class containing connection_id, organization_id, and session_id fields, and added an optional sso field to both AuthenticationSsoFailedPayload and AuthenticationSsoSucceededPayload classes to provide additional SSO context in authentication events

These changes improve type correctness by allowing these fields to be absent when not applicable, preventing serialization issues when the API doesn't return these values.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are straightforward type definition updates that improve correctness. Making fields nullable with defaults prevents runtime errors when the API doesn't return these values. The pattern already exists in the codebase (Profile.custom_attributes), and existing tests pass with empty dict values which are compatible with the new nullable types. No logic changes or security concerns.
  • No files require special attention

Important Files Changed

Filename Overview
src/workos/types/directory_sync/directory_user.py Made custom_attributes nullable with default None, fixed import ordering
src/workos/types/events/authentication_payload.py Added AuthenticationSsoData class and optional sso field to SSO authentication payloads
src/workos/types/user_management/organization_membership.py Made custom_attributes nullable with default None

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class AuthenticationResultCommon {
        +Optional[str] ip_address
        +Optional[str] user_agent
    }
    
    class AuthenticationResultSucceeded {
        +Literal["succeeded"] status
        +str email
    }
    
    class AuthenticationResultFailed {
        +Literal["failed"] status
        +ErrorWithCode error
        +Optional[str] email
        +Optional[str] user_id
    }
    
    class AuthenticationSsoData {
        +Optional[str] connection_id
        +Optional[str] organization_id
        +Optional[str] session_id
    }
    
    class AuthenticationSsoSucceededPayload {
        +Literal["sso"] type
        +Optional[str] user_id
        +Optional[AuthenticationSsoData] sso
    }
    
    class AuthenticationSsoFailedPayload {
        +Literal["sso"] type
        +Optional[AuthenticationSsoData] sso
    }
    
    AuthenticationResultCommon <|-- AuthenticationResultSucceeded
    AuthenticationResultCommon <|-- AuthenticationResultFailed
    AuthenticationResultSucceeded <|-- AuthenticationSsoSucceededPayload
    AuthenticationResultFailed <|-- AuthenticationSsoFailedPayload
    AuthenticationSsoSucceededPayload --> AuthenticationSsoData
    AuthenticationSsoFailedPayload --> AuthenticationSsoData
Loading

Last reviewed commit: 5018d64

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.

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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