Commit 947ab05
committed
fix(rmcp): tolerate empty cacheScope instead of silently dropping the whole result
ListToolsResult/ReadResourceResult.cache_scope: Option<CacheScope> had no
custom deserializer, unlike the sibling ttl_ms field, which already
tolerates out-of-range input via deserialize_ttl_ms. A server sending
cacheScope: "" (SEP-2549 only permits "public"/"private"/absent) failed
deserialization of the whole result - and because ServerResult is
#[serde(untagged)], that failure doesn't surface as an error. It falls
through variant-by-variant to CustomResult (the catch-all), so callers
silently lose typed access to .tools/.contents instead of getting a clear
error or a usable result.
Add deserialize_cache_scope, mirroring the existing deserialize_ttl_ms
normalize-don't-error pattern: "" and null are treated as absent,
everything else delegates to CacheScope's normal deserialization, so a
genuinely invalid value (e.g. "PUBLIC") still errors - it just no longer
takes the whole result down with it.
Add a regression test covering both direct ListToolsResult deserialization
and the full ServerResult untagged path, asserting the tool list survives
instead of degrading to CustomResult.
Signed-off-by: Wahib El Khadiri <wahibelkhadiri06@gmail.com>1 parent fd7811f commit 947ab05
2 files changed
Lines changed: 57 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1660 | 1660 | | |
1661 | 1661 | | |
1662 | 1662 | | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
1663 | 1684 | | |
1664 | 1685 | | |
1665 | 1686 | | |
| |||
1697 | 1718 | | |
1698 | 1719 | | |
1699 | 1720 | | |
1700 | | - | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
1701 | 1726 | | |
1702 | 1727 | | |
1703 | 1728 | | |
| |||
1847 | 1872 | | |
1848 | 1873 | | |
1849 | 1874 | | |
1850 | | - | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
1851 | 1880 | | |
1852 | 1881 | | |
1853 | 1882 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
4 | 29 | | |
5 | 30 | | |
6 | 31 | | |
| |||
0 commit comments