Issue using Microsoft.Testing.Platform in Rider with TUnit
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- csharp
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Start by reading SerializerUtilities.RegisterDeserializers and the ErrorMessage deserializer, then trace how TcpMessageHandler.ReadAsync and ServerTestHost.HandleMessagesAsync handle deserialization failures. Reproduce with the supplied id: null JSON-RPC error response and compare it with the id: 7 control. Done when the null-id response no longer terminates the host and the server continues handling messages.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
In server mode (--server --client-port <N>), a client message that is a JSON-RPC error response with "id": null
makes the host throw an unhandled MessageFormatException: 'id' field is missing. The process dies with exit code
0xE0434352 (-532462766). JSON-RPC 2.0 requires id to be null in an error response when the id of the request could
not be determined (for example after a parse error), so this is a standard message and should not crash the host.
An IDE client (JetBrains Rider 2026.1.4) sends exactly this message after it fails to parse a message from the host, so the
host crash turns one parse problem into a total loss of the test session.
Environment
-
Microsoft.Testing.Platform 2.5.2 (
Microsoft.Testing.Platform.dll2.500.226.52706), hosted by TUnit 1.76.45 -
Target
net48(the only target I tried), Windows 11 Enterprise 10.0.22631, x64
Reproduction (without any IDE)
-
Listen on a loopback TCP port
P. -
Start any MTP test executable:
<Tests>.exe --server --client-port P. It connects toP. -
Send an
initializerequest (framing:Content-Length: <bytes>\r\n\r\nthen the JSON body) and read the response:{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"processId":1,"clientInfo":{"name":"probe","version":"1.0"},"capabilities":{"testing":{"debuggerProvider":false}}}} -
Send this message:
{"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"JSON parse error"}}
Result: the test process exits at once. Its standard output contains:
Unhandled Exception: Microsoft.Testing.Platform.ServerMode.MessageFormatException: 'id' field is missing
at Microsoft.Testing.Platform.ServerMode.SerializerUtilities.GetRequiredPropertyFromJson[T](IDictionary`2 properties, String propertyName)
at Microsoft.Testing.Platform.ServerMode.SerializerUtilities.<>c.<RegisterDeserializers>b__16_12(IDictionary`2 properties)
at Microsoft.Testing.Platform.ServerMode.ObjectDeserializer`1.DeserializeObject(IDictionary`2 properties)
at Microsoft.Testing.Platform.ServerMode.SerializerUtilities.Deserialize(Type t, IDictionary`2 properties)
at Microsoft.Testing.Platform.ServerMode.SerializerUtilities.Deserialize[T](IDictionary`2 properties)
at Microsoft.Testing.Platform.ServerMode.SerializerUtilities.<>c.<RegisterDeserializers>b__16_0(IDictionary`2 properties)
at Microsoft.Testing.Platform.ServerMode.ObjectDeserializer`1.DeserializeObject(IDictionary`2 properties)
at Microsoft.Testing.Platform.ServerMode.SerializerUtilities.Deserialize(Type t, IDictionary`2 properties)
at Microsoft.Testing.Platform.ServerMode.SerializerUtilities.Deserialize[T](IDictionary`2 properties)
at Microsoft.Testing.Platform.ServerMode.TcpMessageHandler.<ReadAsync>d__14.MoveNext()
at Microsoft.Testing.Platform.Hosts.ServerTestHost.<HandleMessagesAsync>d__43.MoveNext()
...
at Microsoft.Testing.Platform.Builder.TestApplication.<RunAsync>d__10.MoveNext()
Exit code: -532462766 (0xE0434352, an unhandled .NET exception).
Control: the same error message with "id": 7 does not crash the host (it stays running).
Cause (from decompiling 2.5.2)
SerializerUtilities.RegisterDeserializers routes any message with an error property to the ErrorMessage deserializer:
if (properties.TryGetValue("error", out object _))
return Deserialize<ErrorMessage>(properties);
and that deserializer does:
object requiredPropertyFromJson = GetRequiredPropertyFromJson<object>(properties, "id");
where
private static T GetRequiredPropertyFromJson<T>(IDictionary<string, object?> properties, string propertyName)
{
object obj = GetOptionalPropertyFromJson(properties, propertyName)
?? throw new MessageFormatException("'" + propertyName + "' field is missing");
...
}
so an id that is present but null is reported as "missing". The MessageFormatException is not caught anywhere in
TcpMessageHandler.ReadAsync / ServerTestHost.HandleMessagesAsync, so it ends the process. (The response path just below
it, for a result message, also requires a non-null id.)
Expected behaviour
-
An error response with
"id": nullis accepted per JSON-RPC 2.0 (ignored or logged), not treated as malformed. -
More generally, a malformed or unexpected message from the client should not terminate the host with an unhandled
exception. The host could log it, answer with a JSON-RPC error where there is an id to answer, and keep serving.
Impact
Rider 2026.1.4's Testing Platform client sends this reply when it cannot parse a message from the host (it miscounts the
Content-Length of messages containing non-ASCII text, which is reported separately to JetBrains). Because the host then
crashes, the IDE shows no tests at all, with no clear message. If MTP tolerated the reply, the failure would at least be
limited to the one message instead of the whole session.
- Ngôn ngữ chính
- C#
- Star
- 1.1k
- Fork
- 312
- Merge trung bình
- 11 giờ 24 phút
- Pull request đã merge (30 ngày)
- 310
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/testfx
-
needs/triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 56/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area/assertion needs/triage
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 42/100
Maintainer thường phản hồi trong vòng 1 ngày
-
type/automation type/test-gap
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 15/100
Maintainer thường phản hồi trong vòng 1 ngày
-
The productive version of Microsoft.Testing.Extensions.HangDump must not reference to a preview version of Microsoft.Diagnostics.NETCore.ClientCó thể đã có người làm @Evangelink đã nhận 13 ngày trước. Đang mởarea/dump external/other
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
microsoft/testfx#11981 · 6 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
type/automation type/tech-debt
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 5/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/testfx
Issue tương tự
-
Assert.That on a null non-generic IEnumerable throws ArgumentNullException, so IsNull() cannot passĐang mởbug P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area/automation area/sdk kind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
unoplatform/uno.templates#2406 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug frontend ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation trivial
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày