Skip to content

[Bug]: DeSerializeRequest throws NotSupportedException for an unrecognised @type #400

Closed

Description

@antoineatstariongroup

What type of issue is this?

  • Bug report
  • Feature request

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of the SysML2.NET
  • I have searched open and closed issues to ensure it has not already been reported

Description

When a request body carries an @type that the request family does not define (e.g. "BranchRequest" instead of "Branch"), DeSerializer.DeSerializeRequest<T> / DeSerializeRequestAsync<T> throws NotSupportedException from RequestDeSerializationProvider.Provide:

System.NotSupportedException: The BranchRequest is not supported by the RequestDeSerializationProvider.
   at SysML2.NET.Serializer.Json.PSM.RequestDeSerializationProvider.Provide(String typeName)
   at SysML2.NET.Serializer.Json.PSM.PsmDeSerializationDispatcher.ReadRequest(...)
   at SysML2.NET.Serializer.Json.DeSerializer.ReadFamilyObject[T](...)

Other malformed payloads surface differently: a missing @type gives a SerializationException, an @type of another request type than T gives a JsonException, and invalid JSON gives a JsonException / InvalidOperationException.

NotSupportedException usually signals "valid input the library cannot handle", so callers that map exceptions to responses (e.g. 400 for malformed input, 501 for unsupported features) misreport a client error. None of these exceptions is documented on IDeSerializer.

Expected: an unrecognised @type in an untrusted payload is reported as malformed input, consistently with the other cases — preferably a JsonException naming the unknown discriminator — and the exceptions are documented with <exception> tags on IDeSerializer. The same applies to the response family (ResponseDeSerializationProvider).

Steps to Reproduce

var deSerializer = new DeSerializer();
using var stream = new MemoryStream(Encoding.UTF8.GetBytes("""{ "@type": "BranchRequest", "name": "feature" }"""));
deSerializer.DeSerializeRequest<BranchRequest>(stream, SerializationModeKind.JSON, false);
// throws NotSupportedException instead of JsonException

System Configuration

  • SysML2.NET version: 0.25.1 (SysML2.NET.Serializer.Json)
  • Environment (Operating system, version and so on): Windows 11
  • .NET Framework version: .NET 10
  • Additional information: Mycelium Fabric currently also catches NotSupportedException when reading request bodies and answers 400.

Activity

  1. added a commit that references this issue on Oct 29, 2026
    85d6994
  2. linked a pull request that will close this issueFix #400 #402on Oct 29, 2026
  3. added a commit that references this issue on Oct 29, 2026
    c755240
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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