Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The spec asks clients to ignore a negative ttlMs and treat it as 0, but each cacheable result's init check also ran on decode and dropped the whole result. The six results now read ttlMs through TtlMsSerializer, the same mechanism as the main-branch fix for DiscoverResult; constructing a result with a negative ttlMs still fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
devcrocod
requested changes
Nov 20, 2026
devcrocod
left a comment
Contributor
There was a problem hiding this comment.
check other ttlMs PRs for using init blocks instead of serializers
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Goal: turn the confirmed review findings on #985 into atomic fixes. Follow-up to #985.
A server that sends
"ttlMs": -1on any of the six cacheable results makes the client fail to decode the whole result. Each result's non-negativeinitcheck also runs on decode. The caching spec says: "IfttlMsis negative, clients SHOULD ignore it and treat it as0."What changed
TtlMsSerializerinserializers.ktreads a negativettlMsas0and writes the value unchanged.ttlMsonDiscoverResult,ListToolsResult,ListPromptsResult,ListResourcesResult,ListResourceTemplatesResultandReadResourceResultuses it through@Serializable(with = TtlMsSerializer::class).initchecks stay, so constructing any of these results with a negativettlMsstill throwsIllegalArgumentException.Scope
#1188 fixes
DiscoverResultonmainwith the same serializer. Theserializers.kthunk is byte-identical in both PRs, and thediscovery.ktchange is the same one annotation line, so rebasing this branch ontomainresolves to the same code.Blast Radius
Inbound decoding of the six cacheable results only. Encoding is unchanged. No public API change, so
checkKotlinAbipasses with no dump update.Verification
CacheableResultTest.a negative freshness window from the wire should read as zerofailed before the fix withJsonDecodingException: Deserialization failed because of 'ttlMs must be non-negative, but was -1', and passes after it.a negative freshness window should be refused at constructionstill passes../gradlew :kotlin-sdk-core:jvmTest ktlintCheck detekt checkKotlinAbipasses.🤖 Generated with Claude Code