Skip to content

fix(core): write null Task.ttl instead of omitting it - #1089

Merged
devcrocod merged 2 commits into
mainfrom
devcrocod/task-ttl-explicit-null
Oct 13, 2026
Merged

devcrocod merged 2 commits into
mainfrom
devcrocod/task-ttl-explicit-null

Conversation

@devcrocod

@devcrocod devcrocod commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Tasks with unlimited retention now go on the wire with "ttl": null: the schema requires the key, and McpJson used to drop it.

closes #1078

How Has This Been Tested?

  • Flipped the TasksTest and NotificationTest cases that asserted the omission, and added cases for GetTaskResult with a null ttl, TaskStatusNotification.toJSON() and decoding a task without ttl. The serialization cases fail without the fix.
  • kotlin-sdk-core JVM tests, the types tests on JS (Node), Wasm (Node) and macosArm64, plus ktlint, detekt and checkKotlinAbi.
  • Checked the encoded CreateTaskResult, GetTaskResult, CancelTaskResult, ListTasksResult and notifications/tasks/status against the TypeScript SDK 1.30.1 schemas: they pass with "ttl": null and fail without the key.

Breaking Changes

None. The public API is unchanged; ttl is now always present on the wire.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

The 2025-11-25 schema requires Task.ttl and uses null for unlimited
retention, but McpJson drops null properties, so such a task went out
without the key. Task, GetTaskResult and TaskStatusNotificationParams
now add "ttl": null when it is missing. Decoding is unchanged.
Copilot AI balanced review requested due to automatic review settings October 1, 2026 15:53
@devcrocod
devcrocod requested a review from e5l October 1, 2026 15:58

Copilot AI left a comment

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.

Copilot review overview

🟢 Approval recommended

The implementation consistently covers affected wire types with focused regression tests and preserves decoding compatibility.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes task serialization to emit required nullable ttl fields, aligning with the MCP 2025-11-25 schema.

Changes:

  • Adds shared serializers that restore "ttl": null.
  • Applies them to all task-state wire types.
  • Expands serialization and backward-compatible decoding tests.
File Description
tasks.kt Applies serializers to task result types.
notification.kt Applies serialization to status notification parameters.
serializers.kt Adds the task-field transforming serializer.
TasksTest.kt Tests task results, lists, and legacy decoding.
NotificationTest.kt Tests notification and JSON-RPC conversion.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice, clean fix — this looks good to merge, thanks!


Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=031d62f9-6886-4d9b-9ee3-2210eb756bf8

@e5l e5l left a comment

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.

lgtm

Copilot AI balanced review requested due to automatic review settings October 13, 2026 17:41

Copilot AI left a comment

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.

🟢 Approval recommended

The implementation consistently addresses all affected task wire formats with appropriate regression coverage.

0 open findings

🧠 Review effort: Balanced

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good — happy to approve this one, thanks!


Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=d9720ab9-3822-4bce-be88-1161eb1fa038

@devcrocod
devcrocod merged commit b17cd35 into main Oct 13, 2026
21 checks passed
@devcrocod
devcrocod deleted the devcrocod/task-ttl-explicit-null branch October 13, 2026 17:59
@jetbrains-air

jetbrains-air Bot commented Oct 13, 2026

Copy link
Copy Markdown

Documentation maintenance — one stale statement, in a file outside this diff (so it could not be anchored inline).

AGENTS.md:69 (also reachable as CLAUDE.md, a symlink to it)

Stale statement

  • McpJson has explicitNulls = false: null properties must be absent from JSON, not "field": null

It is written as an absolute rule: no null property may ever appear on the wire.

The change that falsified it

This PR put Task, GetTaskResult and TaskStatusNotificationParams behind the new TaskFieldsSerializer (@Serializable(with = …) + @KeepGeneratedSerializer), which re-adds "ttl" as JsonNull after McpJson has dropped it. TasksTest and NotificationTest now assert "ttl": null in the encoded output, so the repo's own tests contradict the rule as stated. An agent reading line 69 as written would treat "ttl": null as a violation and revert the fix for #1078.

Suggested correction

Keep the rule as the default and record the schema-mandated exception:

- **`McpJson` has `explicitNulls = false`**: null properties are absent from JSON, not
  `"field": null` — except where the MCP schema requires the key, which a
  `JsonTransformingSerializer` has to re-add (see `TaskFieldsSerializer` for `Task.ttl`)

Nothing else went stale: the ttl KDoc on TaskFields, Task, GetTaskResult and TaskStatusNotificationParams ("null for unlimited") still matches the code, and neither the README, /docs, the Module.md files nor the sample READMEs document tasks or ttl.


Produced by Air Automations. Name: Documentation maintenance / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/78771d31-9b0b-450c-810f-118fb9430a87?run=38406cf9-4f7f-445c-b677-0ea4b3e7349d

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.

Task.ttl is dropped from the wire when it is null

3 participants