Summary
The C# playground server (csharp-playground-server.azurewebsites.net) intermittently returns 500 from POST /generate. The generator subprocess exits with code 1 and logs:
The JSON value could not be converted to Microsoft.TypeSpec.Generator.Input.InputNamespace. Path: $ | LineNumber: 6 | BytePositionInLine: 1.
at Microsoft.TypeSpec.Generator.Input.InputNamespaceConverter.ReadInputNamespace(...)
at Microsoft.TypeSpec.Generator.Input.TypeSpecSerialization.Deserialize(...)
at Microsoft.TypeSpec.Generator.Input.InputLibrary.Load(...)
The stack trace points at InputNamespaceConverter.ReadInputNamespace, where the only JsonException for the root is name ?? throw — i.e. the root code model object has no name property (the root object ends by line 6, so the document the generator parsed is tiny/truncated).
Why this is suspicious
- The failure is non-deterministic for specs that always declare a namespace.
- Deserializing a fixed JSON document is deterministic and single-threaded, and the playground server writes each request to a unique temp dir, so the same bytes can't parse differently across runs.
- Therefore the bytes reaching the generator must differ between runs — the code model appears to be mangled/truncated somewhere between the browser emitter producing it and the generator parsing it (transport, the server's write path, or the emitter's serialization).
Current gap
The bare throw new JsonException() produces an opaque could not be converted to InputNamespace with no indication of which field is missing, and the server keeps no fingerprint of the payload, so the corruption can't be localized from telemetry.
Proposed work (diagnostics first)
- Generator: make the exception name the missing
name field (keep STJ Path/line/byte).
- Playground server: log a SHA-256 of the received code model (identical specs must hash identically), and add a write/read integrity check to flag server-side mangling.
Once telemetry confirms where the bytes diverge (transport vs. server write vs. emitter output) we can fix the root cause.
A first PR adding the diagnostics + a descriptive error is linked below.
Summary
The C# playground server (
csharp-playground-server.azurewebsites.net) intermittently returns 500 fromPOST /generate. The generator subprocess exits with code 1 and logs:The stack trace points at
InputNamespaceConverter.ReadInputNamespace, where the onlyJsonExceptionfor the root isname ?? throw— i.e. the root code model object has nonameproperty (the root object ends by line 6, so the document the generator parsed is tiny/truncated).Why this is suspicious
Current gap
The bare
throw new JsonException()produces an opaquecould not be converted to InputNamespacewith no indication of which field is missing, and the server keeps no fingerprint of the payload, so the corruption can't be localized from telemetry.Proposed work (diagnostics first)
namefield (keep STJ Path/line/byte).Once telemetry confirms where the bytes diverge (transport vs. server write vs. emitter output) we can fix the root cause.
A first PR adding the diagnostics + a descriptive error is linked below.