Skip to content

Event color cannot be cleared because colorId = null is omitted during serialization #324

Closed

Description

@burtonrhodes

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

  1. Create or update an event with a non-null colorId.
  2. Update the same event with colorId = null.
  3. Observe that the event color is not cleared because the colorId field 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:

  1. Update the SDK documentation to note that setting colorId = "0" will clear colors for Google calendars - although not officially supported by Google documentation.
  2. Modify the SDK serialization logic to allow explicit null values to be sent for fields where null has 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

  1. googsvg commented on May 19, 2026

    @googsvg
    Contributor

    tnx for reporting, will be tackled soon

  2. googsvg commented on May 19, 2026

    @googsvg
    Contributor

    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.

  3. burtonrhodes commented on May 19, 2026

    @burtonrhodes
    ContributorAuthor

    Sounds good! Thanks

  4. self-assigned this
    on May 19, 2026
  5. googsvg commented on May 21, 2026

    @googsvg
    Contributor

    should be solved in v2.16.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions