PathSegmentTemplateMatcher accepts conflicting captures for repeated variable names
I maintainer di solito rispondono entro 3 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 64/100
Direzione di ricerca
Inizia da PathSegmentTemplateMatcher (io.modelcontextprotocol.kotlin.sdk.utils): individua il ciclo di corrispondenza a passaggio singolo che scrive ogni cattura nella mappa variables, insieme alla decodifica percentuale e alla logica di scoring che lo circondano. Riproduci il problema con lo snippet nell'issue, poi aggiungi unit test per catture diverse, catture uguali, uguaglianza dopo la decodifica e nomi indipendenti, ed esegui la suite di test JVM del core e ServerResourceTemplateTest. È completato quando un nome ripetuto con valori decodificati diversi non restituisce corrispondenze, 42/42 continua a corrispondere e i nomi distinti, lo scoring e i limiti di profondità restano invariati. Nota che dal lato di chi ha segnalato esiste già un candidato di correzione locale: coordinati prima di duplicarlo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
PathSegmentTemplateMatcher accepts conflicting values for a repeated variable name and retains only the last capture. A resource request can therefore match a template whose repeated variable cannot explain the request consistently.
This was identified by @chrikrah in the review of #1175. This issue tracks the matching behavior separately from #1084's depth-check allocation fix.
Reproduction
import io.modelcontextprotocol.kotlin.sdk.types.ResourceTemplate
import io.modelcontextprotocol.kotlin.sdk.utils.PathSegmentTemplateMatcher
fun main() {
val matcher = PathSegmentTemplateMatcher(
ResourceTemplate("test://items/{id}/{id}", "Repeated ID"),
)
println(matcher.match("test://items/42/43"))
check(matcher.match("test://items/42/43") == null)
}
Actual: the URI matches with variables = {id=43}; the first capture is overwritten and the check fails. The same template with 42/42 matches consistently and should keep doing so.
Expected: reject a match when a repeated name captures different values, using the matcher's existing one-pass percent-decoding semantics. Keep consistent repeated captures, distinct names, scoring, URI normalization and depth limits unchanged.
Version check
The same six tests against the latest release tag 0.16.0 (4c55826) have three failures and three passing controls. The inconsistent repeated captures are accepted there too.
Candidate and local validation
A local candidate checks an existing capture before overwriting it. Six tests cover differing captures, equal captures and their score, decoded equality, a differing third occurrence, independent names and one-pass decoding.
On reviewed head 0f6a84c, three of those six cases fail without the candidate. With it, all 278 core JVM tests and nine ServerResourceTemplateTest integration tests pass. Core ktlint, Kotlin ABI and diff checks pass. These are local results on macOS arm64 with Temurin 21; JS, Native and Wasm runtime tests and detekt were not run for this candidate.
The existing #1175 branch remains unchanged. This candidate intentionally rejects some previously accepted URIs, so a separate follow-up keeps that behavior change reviewable without expanding the allocation PR. No production impact or full multiplatform validation is claimed.
- Lingua principale
- Kotlin
- Stelle
- 1.5k
- Fork
- 270
- Merge medio
- 3g 7h
- PR unite (30g)
- 59
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelcontextprotocol/kotlin-sdk
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
modelcontextprotocol/kotlin-sdk#1088 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 3 giorni
-
An empty URI matches a single-variable resource templateForse già presa @liyifan9642-creator l’ha presa 43 giorni fa. Apertabug P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
modelcontextprotocol/kotlin-sdk#1085 ·
I maintainer di solito rispondono entro 3 giorni
-
AbstractClientTransport.checkState builds a broken error messageForse già presa @mvanhorn l’ha presa 36 giorni fa. Apertaapi bug P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
modelcontextprotocol/kotlin-sdk#1083 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
ModelPreferences reports an invalid speedPriority as costPriorityForse già presa @sarankumar1325 l’ha presa 25 giorni fa. Apertabug P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
modelcontextprotocol/kotlin-sdk#1081 ·
I maintainer di solito rispondono entro 3 giorni
-
Document elicitationApertadocumentation P2
Difficoltà 2/5 1-2 giorni Idoneità per principianti 74/100
modelcontextprotocol/kotlin-sdk#1074 ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di modelcontextprotocol/kotlin-sdk
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
krelltunez/dayGLANCE#2445 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
EANs strippenApertagood first issue prio:P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
haritpanchal/WakeGuard#16 ·
-
After turning shuffle on while paused, a different song is the current one when the app is reopenedApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
RetroMusicPlayer/RetroMusicPlayer#2085 ·
I maintainer di solito rispondono entro 1 giorno