Skip to content

fix: correct Nullable<T> detection in transpiler and CLI output deadlock in Aspire hosting - #1286

Merged
kimpenhaus merged 3 commits into
mainfrom
fix/process-output-and-nullable-detection
Oct 15, 2026
Merged

kimpenhaus merged 3 commits into
mainfrom
fix/process-output-and-nullable-detection

Conversation

@kimpenhaus

Copy link
Copy Markdown
Collaborator

Summary

Two independent bug fixes that surfaced while reviewing the .NET 11 migration (#1285). Both apply to all currently supported target frameworks, so they are shipped separately from that PR.

1. Transpiler: wrong nullable: true in generated CRDs

Utilities.IsNullable(Type) / IsNullable(PropertyInfo) treated every type whose FullName contains "Nullable" as nullable. The full name of a constructed generic type includes its type arguments, so for example:

Property type Before After
IEnumerable<int?> nullable: true ❌ not nullable ✅ (items stay nullable: true)
type named e.g. NonNullableSettings nullable: true ❌ not nullable ✅
int?, string?, MyEnum? … nullable: true nullable: true (unchanged)

The check now compares the generic type definition by name (System.Nullable1), which also works for types loaded through MetadataLoadContext(wheretypeof(Nullable<>)` identity does not hold).

Regenerating CRDs may remove incorrect nullable: true entries from properties of affected types. This makes the schema stricter (null is no longer accepted for those properties), matching the C# declaration.

2. Aspire hosting: manifest publishing could hang

RunKubeOpsGenerator read the KubeOps CLI's stdout to the end and only then read stderr. If the CLI wrote more than the OS pipe buffer (~64 KiB) to stderr, e.g. on a verbose build failure, it blocked on that write while the host waited for stdout to close. Publishing then hung indefinitely. stderr is now drained asynchronously while stdout is consumed (RunKubectlAsync in the same file already did this).

RunKubeOpsGenerator is now internal (instead of private) so it can be tested directly.

Tests

  • CrdsMlcTest.Should_Transpile_Entity_Type_Correctly: new cases for IEnumerable<int?> and a type with "Nullable" in its name. Both failed before the fix with Expected <null>, but found True.
  • KubeOpsHostingGeneratorTest.RunKubeOpsGenerator_Does_Not_Block_On_Large_Stderr_Output: simulates the CLI with /bin/sh, writing 256 KiB to stderr and exiting with code 3 (skipped on Windows). Before the fix it hit the 30 s timeout. Now it fails fast with the CLI error, including the full stderr output.

Verification

  • dotnet build --configuration Release: 0 warnings, 0 errors
  • dotnet format --verify-no-changes: clean
  • dotnet test --configuration Release against a local cluster: 842 total, 834 passed, 8 skipped, 0 failed

IsNullable checked whether the type's full name contains "Nullable".
The full name of a constructed generic type includes its type arguments,
so properties such as IEnumerable<int?> were emitted with nullable: true,
as was any type whose name contains "Nullable". Compare the generic type
definition by name instead, which also works for MetadataLoadContext types.
RunKubeOpsGenerator read stdout to the end before reading stderr. When the
CLI wrote more than the pipe buffer to stderr, it blocked on the write
while the host waited for stdout to close, hanging manifest publishing
indefinitely. Read stderr asynchronously while stdout is consumed.
@kimpenhaus
kimpenhaus enabled auto-merge (squash) October 15, 2026 20:30
@kimpenhaus
kimpenhaus merged commit a55758d into main Oct 15, 2026
4 checks passed
@kimpenhaus
kimpenhaus deleted the fix/process-output-and-nullable-detection branch October 15, 2026 20:37
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 13.3.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant