fix: omit SerializedMember 'name' when null to honor output schema#87
Merged
Conversation
SerializedMemberConverter.Write always wrote the "name" property, emitting JSON null for value-only / root / unnamed members. The converter's own schema types "name" as a non-nullable "string" and does not list it in "required", so "name": null violated the advertised output schema and strict MCP clients (e.g. Copilot) rejected the tool result with -32602. Write "name" only when non-null. An absent non-required key is schema-valid; a present key is always a string. The schema is left unchanged (NOT widened to ["string","null"] — PostprocessFields strips "null" from type unions). Adds regression tests covering null-name omission, non-null string emission, the schema contract (name typed string, not required), and round-trip stability. verified-downstream: McpPlugin.Tests, McpPlugin.Server.Tests, Unity-EditMode Closes #86
Contributor
The existing facts cover null-name omission only at the flat/root level. Add a regression test for the recursive case from issue #86: a SerializedMember tree whose fields/props children have a null name. Because children are serialized through the same converter, the omit-when-null behavior must hold at every depth — real tool outputs (assets-get-data, gameobject-component-get) return nested trees whose value-only leaves legitimately have null names. Asserts each nested child object omits the "name" key while the parent's name and every typeName are preserved. Closes #86
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.
Summary
SerializedMemberConverter.Writenow omits thenameproperty when it is null instead of writing"name": null, which violated the converter's own output JSON Schema (which typesnameas a non-nullablestringand does not list it inrequired). Strict MCP clients (e.g. Copilot) were rejectingSerializedMember-returning tool results with-32602.["string","null"]—PostprocessFieldsstrips"null"from type unions). An absent non-required key is schema-valid; a present key is always a string.string, not required), and round-trip stability.Test plan
Closes #86