Event color cannot be cleared because colorId = null is omitted during serialization #324
Description
Describe the bug
Commit d79b0e2 in #322 introduced a regression when updating calendar events. The Nylas documentation states that setting colorId to null should clear the event color. However, the Java SDK omits null fields during Jackson serialization, so colorId is not included in the request payload and the existing color remains unchanged.
As a result, there is currently no documented way to clear an event color using the Java SDK.
To Reproduce
- Create or update an event with a non-null
colorId. - Update the same event with
colorId = null. - Observe that the event color is not cleared because the
colorIdfield is omitted from the serialized JSON payload.
Expected behavior
When colorId is set to null, the SDK should send "color_id": null so that the Nylas API can clear the event color as documented.
SDK Version:
#322
Additional context
There is undocumented Google-specific behavior that will clear the color when setting color_id equal to "0".
There are two possible approaches to resolve this issue:
- Update the SDK documentation to note that setting
colorId = "0"will clear colors for Google calendars - although not officially supported by Google documentation. - Modify the SDK serialization logic to allow explicit
nullvalues to be sent for fields wherenullhas semantic meaning.
The second approach seems like the better long-term solution, since other fields may also require explicit null values in future API updates. The first approach is obviously a trivial update
I am curious which path the maintainers would like to pursue.
Activity
googsvg commentedon May 19, 2026
tnx for reporting, will be tackled soon
googsvg commentedon May 19, 2026
Thanks for the detailed report! This is now fixed.
The root cause was that Moshi (our JSON serialization library) silently drops null fields by default, so there was no way to distinguish between "field not set" and "field
explicitly cleared".
We introduced a NullableField type that models three states cleanly: omit, set a value, or explicitly clear. The builder now has a clearColorId() method that sends
"color_id": null on the wire.
Usage going forward:
// Set a color
UpdateEventRequest.Builder().colorId("3").build()
// Clear a color
UpdateEventRequest.Builder().clearColorId().build()
// Don't touch the color (omits the field entirely)
UpdateEventRequest.Builder().title("foo").build()
This will be available in the next release. Thanks again for the thorough bug report and the suggested solution — it pointed us in exactly the right direction.
burtonrhodes commentedon May 19, 2026
Sounds good! Thanks
googsvg commentedon May 21, 2026
should be solved in v2.16.1