Skip to content

fix(directory-sync): Add name to DirectoryUser - #1731

Open
gjtorikian wants to merge 1 commit into
mainfrom
fix/1700-directory-user-name
Open

gjtorikian wants to merge 1 commit into
mainfrom
fix/1700-directory-user-name

Conversation

@gjtorikian

Copy link
Copy Markdown
Contributor

Description

The API returns a composed name on directory users and the OpenAPI spec declares it (DirectoryUser.name: string | null), but DirectoryUser and DirectoryUserResponse did not model it, so deserializeDirectoryUser and deserializeUpdatedEventDirectoryUser silently dropped it. Identity providers that map only the composed name leave SDK consumers with no name at all, for both API responses and dsync.user.* events.

  • Add name: string | null to DirectoryUser and DirectoryUserResponse.
  • Carry it through both deserializers, normalizing a missing value to null (same as deserializeUser).
  • Add name to the dsync.user.created webhook fixture and the dsync.user.updated event test so both deserializers are covered.

The spec also types organization_id as a non-nullable string while the SDK types it string | null; that is left as is here since changing it would be a breaking type change.

Fixes #1700

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.

The API returns a composed `name` on directory users, and the OpenAPI
spec declares it as `string | null`, but `DirectoryUser` and
`DirectoryUserResponse` did not model it, so both directory user
deserializers dropped it. Identity providers that map only the composed
name, and neither `first_name` nor `last_name`, left SDK consumers with
no name at all for API responses and `dsync.user.*` events.

Add `name` to both interfaces and carry it through
`deserializeDirectoryUser` and `deserializeUpdatedEventDirectoryUser`,
normalizing a missing value to `null` like the user deserializer does.

Fixes #1700
@gjtorikian
gjtorikian requested review from a team as code owners October 20, 2026 21:17
@greptile-apps

greptile-apps Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change reaches directory-user API results and directory-sync event workflows.

The PR appears safe to merge, with a non-blocking request to test missing and null names.

Findings

  1. P2 Missing names go untested ▶
Fix with agent prompt
### Issue 1
src/directory-sync/serializers/directory-user.serializer.ts:27
Both new tests supply a non-null `name`, so neither checks the new `?? null` fallback. Add cases with `name` omitted and explicitly null for both deserializers, and assert that the returned `name` is null. Otherwise, removing the fallback would leave these tests passing while older payloads return undefined.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds name to directory-user types and preserves it in API responses and updated events.

  • Directory-user results now include the composed name.

Reviews (1) · Last reviewed commit: "fix(directory-sync): Add name to Directo..." · Reviewed by Greptile

firstName: directoryUser.first_name,
email: directoryUser.email,
lastName: directoryUser.last_name,
name: directoryUser.name ?? null,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Missing names go untested

Both new tests supply a non-null name, so neither checks the new ?? null fallback. Add cases with name omitted and explicitly null for both deserializers, and assert that the returned name is null. Otherwise, removing the fallback would leave these tests passing while older payloads return undefined.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/directory-sync/serializers/directory-user.serializer.ts
Line: 27

Comment:
**Missing names go untested**

Both new tests supply a non-null `name`, so neither checks the new `?? null` fallback. Add cases with `name` omitted and explicitly null for both deserializers, and assert that the returned `name` is null. Otherwise, removing the fallback would leave these tests passing while older payloads return undefined.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

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.

DirectoryUser omits the name field that the API and OpenAPI spec return

2 participants