Skip to content

Handle unreadable string values from peer JSON in core without -32603 #2063

Backlog

Description

@tarekgh

Follow-up to #2014.

#2014 makes Streamable HTTP POST validation return 400 / -32600 when a request contains a value that cannot be read, and makes McpServerImpl.ReadRequestMetadata treat an unreadable _meta protocol version as missing. Other places in core still read strings from peer-supplied JSON with GetValue<string>(), which throws InvalidOperationException when:

  • a string value is not valid UTF-8 (Utf8JsonReader only validates it when the token is converted to a .NET string),
  • the value is an escaped lone surrogate such as "\uD800",
  • any property name in the containing JsonObject is not valid UTF-8 (the first lookup converts all property names), or
  • the value is not a string.

When this happens during request processing, the peer gets a generic internal error (-32603) instead of an error that identifies the request as malformed.

Sites to review:

For each site that reads peer input, decide whether an unreadable value should be rejected as -32600 / -32602 or treated as missing, and add tests with invalid UTF-8 values and property names.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions