Uh oh!
There was an error while loading. Please reload this page.
fix(elicitation): preserve enumNames through ElicitationSchema serde round-trip - #905
Conversation
…round-trip UntitledSingleSelectEnumSchema lacked deny_unknown_fields, so a legacy enum payload containing enumNames was silently matched by that variant (ignoring the field) rather than falling through to LegacyEnumSchema. The enumNames array was lost on re-serialization. Add deny_unknown_fields to UntitledSingleSelectEnumSchema so that any unknown field (including enumNames) causes serde to try the next untagged variant, reaching LegacyEnumSchema correctly. Also add skip_serializing_if = "Option::is_none" to LegacyEnumSchema::enum_names so that an untitled legacy enum without enumNames does not serialize "enumNames": null. Fixesmodelcontextprotocol#903
michaelneale
commented
Jun 17, 2026
@abdouloued do you want to fix up the failures and we can take a look again? |
…_fields deny_unknown_fields on UntitledSingleSelectEnumSchema makes schemars emit additionalProperties: false for that definition. Regenerate the golden schema fixtures to match (UPDATE_SCHEMA=1 cargo test -p rmcp --test test_message_schema --all-features).
abdouloued
commented
Jun 19, 2026
Pushed a fix. The failure appears to be a stale golden-file schema snapshot ( Regenerated it with Looks like the workflow run needs approval to kick off again on this push. |
DaleSeo
left a comment
There was a problem hiding this comment.
Thanks for the fix, @abdouloued!
Uh oh!
There was an error while loading. Please reload this page.
Fixes#903.
Problem
EnumSchemais#[serde(untagged)]with variants orderedSingle → Multi → Legacy.SingleSelectEnumSchemais itself untagged withUntitledbeforeTitled.UntitledSingleSelectEnumSchemadid not havedeny_unknown_fields, so a legacy payload like:{"type":"string","enum":["opt1","opt2","opt3"],"enumNames":["Option One","Option Two","Option Three"]}was silently matched by
UntitledSingleSelectEnumSchema(which has noenumNamesfield). The array was dropped, andLegacyEnumSchemawas never tried. On re-serialization,enumNameswas gone.A secondary issue:
LegacyEnumSchema::enum_nameslackedskip_serializing_if = "Option::is_none", so aLegacywithenum_names: Nonewould serialize"enumNames": null.Fix
deny_unknown_fieldstoUntitledSingleSelectEnumSchema. WhenenumNames(or any unrecognised field) is present, serde rejects this variant and falls through toLegacyEnumSchema.skip_serializing_if = "Option::is_none"toLegacyEnumSchema::enum_names.Two regression tests added:
test_legacy_enum_schema_roundtrip_preserves_enum_names— mirrors the exact repro from the issue; verifies that a fullElicitationSchemaround-trip keepsenumNamesintact.test_legacy_enum_schema_no_enum_names_omits_field— verifiesLegacyEnumSchemawithenum_names: Nonedoes not emit"enumNames": null.All existing elicitation tests continue to pass.