Skip to content

TW-5091: nullable calendar color id fix#325

Open
googsvg wants to merge 2 commits into
mainfrom
TW-5091-java-sdk-event-color-cannot-be-cleared-because-color-id-null-is-omitted-during-serialization
Open

TW-5091: nullable calendar color id fix#325
googsvg wants to merge 2 commits into
mainfrom
TW-5091-java-sdk-event-color-cannot-be-cleared-because-color-id-null-is-omitted-during-serialization

Conversation

@googsvg
Copy link
Copy Markdown
Contributor

@googsvg googsvg commented May 19, 2026

Fixes issue #324

Introduces NullableField<T> to model three serialization states (omit / set / explicit null),
and adds UpdateEventRequest.Builder.clearColorId() which sends "color_id": null to the API.

Previously there was no way to clear an event color — null fields were silently dropped by Moshi.

License

I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 19, 2026

Codecov Report

❌ Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.74%. Comparing base (6b648b3) to head (e03921c).

Files with missing lines Patch % Lines
...tlin/com/nylas/util/NullableFieldAdapterFactory.kt 95.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #325      +/-   ##
============================================
+ Coverage     82.49%   82.74%   +0.25%     
- Complexity      358      361       +3     
============================================
  Files            38       39       +1     
  Lines          1034     1055      +21     
  Branches         95       99       +4     
============================================
+ Hits            853      873      +20     
  Misses          122      122              
- Partials         59       60       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@playerzero-ai
Copy link
Copy Markdown

playerzero-ai Bot commented May 19, 2026

PlayerZero

TW-5091-java-sdk-event-color-cannot-be-cleared-because-color-id-null-is-omitted-during-serializationmain

Change Summary

TW-5091: nullable calendar color ID fix

  • Introduced NullableField<T> to represent three distinct request states:
    • null on the Kotlin model = omit field
    • NullableField.Value(v) = serialize a concrete value
    • NullableField.Clear = serialize explicit JSON null
  • Added NullableFieldAdapterFactory and registered it in the shared JsonHelper Moshi stack so explicit clears survive serialization without changing global null-handling behavior.
  • Updated UpdateEventRequest.colorId to use NullableField<String>? and added:
    • colorId("11") → sends "color_id": "11"
    • clearColorId() → sends "color_id": null
  • Kept the change localized to the event update flow used by Events.update(...); create-event behavior and other request models are unchanged.
  • Expanded tests to verify:
    • color_id is omitted when unset
    • color_id serializes normally when set
    • clearColorId() emits an explicit null payload for clearing the Google Calendar event color

updated: May 19 @ 07:51 PM UTC

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