-
Notifications
You must be signed in to change notification settings - Fork 441
Fix ResourceLinkBlock deserialization by adding missing "name" case #645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+87
−0
Conversation
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
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Copilot finished work on behalf of
eiriktsarpalis
July 23, 2025 12:55
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Copilot finished work on behalf of
eiriktsarpalis
July 23, 2025 15:13
eiriktsarpalis
approved these changes
Jul 23, 2025
stephentoub
reviewed
Jul 23, 2025
stephentoub
approved these changes
Jul 23, 2025
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot finished work on behalf of
stephentoub
July 23, 2025 16:18
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.
Summary
Fixed a critical deserialization bug in
ResourceLinkBlock
where the "name" property was not being read from JSON, causing aJsonException
to be thrown during deserialization.Problem
When attempting to deserialize a
ResourceLinkBlock
from JSON, the following exception was thrown:This occurred because the
ContentBlock.Converter.Read
method was missing a switch case for the "name" property, even though:name
variable was declared (line 75)name
property was being written correctly during serialization (line 245)name
variable was expected to be non-null when creating theResourceLinkBlock
(line 178)Root Cause
In
src/ModelContextProtocol.Core/Protocol/ContentBlock.cs
, the switch statement in theRead
method (lines 96-140) was missing a case for"name"
, causing the name property to remainnull
during deserialization.Solution
Added the missing switch case to properly handle the "name" property during JSON deserialization:
Testing
ResourceLinkBlock
now serializes and deserializes correctlyuri
,name
) are preserved during round-trip serializationdescription
,mimeType
,size
) are also handled correctlyContentBlockTests.cs
to prevent regressionContentBlock
types (TextContentBlock
,ImageContentBlock
, etc.) continue to work correctlyExample
Before this fix:
After this fix:
Fixes #644.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
aka.ms
curl -I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 REDACTED
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.