Skip to content

Fix custom attributes to be nullable#559

Closed
blackmad-cradle wants to merge 2 commits intoworkos:mainfrom
blackmad-cradle:fix-custom-attributes-to-be-nullable2
Closed

Fix custom attributes to be nullable#559
blackmad-cradle wants to merge 2 commits intoworkos:mainfrom
blackmad-cradle:fix-custom-attributes-to-be-nullable2

Conversation

@blackmad-cradle
Copy link
Contributor

Description

Deserializing these events via list calls is crashing on custom_attributes being missing.

The API docs should possibly be updated to show that this dict can be null

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.

@blackmad-cradle blackmad-cradle requested a review from a team as a code owner February 20, 2026 10:07
@blackmad-cradle blackmad-cradle force-pushed the fix-custom-attributes-to-be-nullable2 branch from 69dd994 to 780a05e Compare February 20, 2026 10:07
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 20, 2026

Greptile Summary

Made custom_attributes field optional in DirectoryUser and OrganizationMembership models to fix deserialization crashes when the API returns responses without this field.

  • Changed custom_attributes: Dict[str, Any] to custom_attributes: Optional[Dict[str, Any]] = None in DirectoryUser
  • Changed custom_attributes: Mapping[str, Any] to custom_attributes: Optional[Mapping[str, Any]] = None in OrganizationMembership
  • Aligns with existing pattern used in Profile type where custom_attributes is also optional
  • Prevents Pydantic validation errors when deserializing API responses that omit the custom_attributes field

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The change is a straightforward bug fix that makes custom_attributes optional with a default value of None, preventing deserialization crashes. The fix aligns with the existing pattern used in the Profile type and matches how Pydantic models handle optional fields. No logic changes, no security concerns, and the change is backwards compatible.
  • No files require special attention

Important Files Changed

Filename Overview
src/workos/types/directory_sync/directory_user.py Made custom_attributes optional with default None to prevent deserialization crashes when field is missing from API response
src/workos/types/user_management/organization_membership.py Made custom_attributes optional with default None to prevent deserialization crashes when field is missing from API response

Last reviewed commit: 780a05e

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.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@mattgd
Copy link
Contributor

mattgd commented Feb 20, 2026

Thanks for bringing this to our attention @blackmad-cradle. From the discussion in your Slack channel, we ended up taking a slightly different approach to the fix in #560. This has been release in v5.42.1. Let us know if you're still experiencing issues with that version.

@mattgd mattgd closed this Feb 20, 2026
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

Comments