Skip to content

fix(integrations/zendesk): Prevent nullable user fields#15225

Merged
mikee-b merged 3 commits into
masterfrom
mb/fix-zendesk-nullable-fields
May 28, 2026
Merged

fix(integrations/zendesk): Prevent nullable user fields#15225
mikee-b merged 3 commits into
masterfrom
mb/fix-zendesk-nullable-fields

Conversation

@mikee-b
Copy link
Copy Markdown
Contributor

@mikee-b mikee-b commented May 28, 2026

Resolves BE-1330

Zendesk custom user fields are nullable, but the type in our action's output is not. Allowing null values would've been breaking, so instead we filter out null values.

@mikee-b mikee-b requested a review from a team as a code owner May 28, 2026 14:47
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 28, 2026

BE-1330

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 28, 2026

Greptile Summary

This PR fixes a type mismatch where Zendesk custom user fields can return null values from the API, but the action output schema declared them as non-nullable strings. Rather than widening the output type (which would be breaking), null entries are now filtered out before the data reaches consumers.

  • _zdUserSchema is extended to accept z.record(z.string().nullable()) when parsing raw Zendesk responses, then transformUser uses pickBy with a type-guard predicate to strip null-valued keys before returning the non-nullable User type.
  • The version is bumped from 3.1.2 to 3.1.3 to reflect the patch.

Confidence Score: 5/5

This is a small, well-scoped fix that correctly handles nullable Zendesk user fields without changing the output contract.

The change is minimal and correct: the schema extension allows null values only in the intermediate parsing layer, and the pickBy filter reliably removes them before the data is returned to callers. No existing API contract is changed.

No files require special attention.

Important Files Changed

Filename Overview
integrations/zendesk/src/definitions/schemas.ts Extends _zdUserSchema to accept nullable user field values from Zendesk, then filters nulls out in transformUser before returning the non-nullable output type.
integrations/zendesk/integration.definition.ts Patch version bump from 3.1.2 to 3.1.3 to reflect the bug fix.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Zendesk API Response\nuser_fields: { k: string | null }"] --> B["_zdUserSchema.parse()\n(now accepts nullable values)"]
    B --> C["ZendeskUser\nuser_fields: Record<string, string | null> | undefined"]
    C --> D["transformUser()"]
    D --> E{"user_fields\ntruthy?"}
    E -- "Yes" --> F["pickBy(user_fields,\nvalue !== null)"]
    F --> G["userFields: Record<string, string>\n(nulls removed)"]
    E -- "No" --> H["userFields: undefined"]
    G --> I["User output\nuserFields: z.record(z.string()).optional()"]
    H --> I
Loading

Reviews (2): Last reviewed commit: "changed zendesk user schema" | Re-trigger Greptile

@mikee-b mikee-b changed the title fix(integrations/zendesk): Allow nullable user fields fix(integrations/zendesk): Prevent nullable user fields May 28, 2026
@mikee-b
Copy link
Copy Markdown
Contributor Author

mikee-b commented May 28, 2026

@greptile review again

Copy link
Copy Markdown
Contributor

@makhlouf1102 makhlouf1102 left a comment

Choose a reason for hiding this comment

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

LGTMT

@mikee-b mikee-b merged commit 2e45178 into master May 28, 2026
10 checks passed
@mikee-b mikee-b deleted the mb/fix-zendesk-nullable-fields branch May 28, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants