Skip to content

Surface silent integration-assembly load failures (#16729) - #16733

Closed
David Pine (IEvangelist) wants to merge 3 commits into
microsoft:mainfrom
IEvangelist:dapine/fix-resolver-silent-loader-failures-16729
Closed

David Pine (IEvangelist) wants to merge 3 commits into
microsoft:mainfrom
IEvangelist:dapine/fix-resolver-silent-loader-failures-16729

Conversation

@IEvangelist

@IEvangelist David Pine (IEvangelist) commented May 4, 2026 •

Copy link
Copy Markdown
Member

Description

This PR hardens the diagnostic chain so that when the integration-assembly load path does fail — for any reason: build-pipeline version skew, stale local NuGet cache, transitive dependency mismatch, partially populated probe directory, etc. — the failure is loud and self-explanatory instead of surfacing only as:

No code generator found for language: TypeScript
No language support found for: typescript/nodejs

The original report (#16729) was a cryptic CLI failure on aspire new with TypeScript templates. After investigation, that specific symptom traced to a stale local NuGet cache anomaly on the reporter''s machine (a mix of package contents from switching between PR / staging / stable 13.3.0 builds) and is not reproducible after clearing ~/.nuget and ~/.aspire. So this PR no longer attempts a runtime binding fix — it is diagnostic hardening only, which is the part that has lasting value regardless of which upstream condition produced the resolver miss.

Changes

  • CodeGeneratorResolver / LanguageSupportResolver now log ReflectionTypeLoadException at Warning level and include the LoaderExceptions text in the message (was previously LogDebug, which is below the file logger''s default Information threshold and never reached the user log).
  • When an assembly named like Aspire.Hosting.CodeGeneration.* is loaded but contributes zero ICodeGenerator / ILanguageSupport types, log a Warning so the silent-failure case is visible.
  • AssemblyLoader.LoadAssemblies performs an Aspire.TypeSystem version sanity check at startup against the libs directory and warns when the bundled and probed versions diverge — surfacing this lets us catch build-pipeline regressions early even if the runtime tolerates the skew.
  • LanguageService / CodeGenerationService error messages now list the available languages, or point at the apphost-server log + binary mismatch when zero are discovered.
  • PrebuiltAppHostServer promotes spawned-process stdout/stderr capture from Trace to Debug/Information, so warnings emitted by the apphost server actually reach the default file log.

Internal-only API additions

  • CodeGeneratorResolver.GetSupportedLanguages() so the service can list available languages in error messages.
  • An internal test-only constructor on both resolvers that takes a Func<IReadOnlyList<Assembly>>, used by the new tests.
  • IntegrationLoadContext.GetSharedAssemblyNames() so the assembly loader''s version sanity check stays in sync with the actual load context policy.

Tests

New coverage in tests/Aspire.Hosting.RemoteHost.Tests/:

  • ResolverDiagnosticsTests (4) — proves the resolvers log Warnings on zero-contributor assemblies and on ReflectionTypeLoadException.
  • ServiceErrorMessageTests (4) — proves the user-visible error messages list available languages or point at the binary-mismatch scenario.

All Aspire.Hosting.RemoteHost.Tests pass locally.

Notes

  • Re-targeted from release/13.3 to main. The branch was reset to upstream/main and the diagnostic commit was cherry-picked clean.
  • An earlier revision of this PR also contained an IntegrationLoadContext.Load change that resolved Aspire.TypeSystem by simple name from the default ALC, intended to tolerate 42.42.42.42 ↔ 13.3.0.0 version skew. That change has been dropped along with its regression test, since the originally-reported failure turned out to be a local cache anomaly rather than a build-pipeline skew, and shipping a binding-policy change without a confirmed root cause to defend against would be premature. The hardening here keeps that scenario visible if it ever does occur.

Closes #16729

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes — ResolverDiagnosticsTests (4) and ServiceErrorMessageTests (4) covering the new diagnostic paths.
  • Did you add public API?
    • No — CodeGeneratorResolver.GetSupportedLanguages(), the additional resolver constructors, and IntegrationLoadContext.GetSharedAssemblyNames() are all internal; the resolvers themselves are internal sealed.
  • Does the change make any security assumptions or guarantees?
    • No
  • Does the change require an update in our Aspire docs?
    • No

@github-actions

github-actions Bot commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16733

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16733"

@joperezr

Copy link
Copy Markdown
Member

I'm still not fully following how does someone reach this in real life. What is the main scenario here of a realistic app that would be broken by this?

@IEvangelist

David Pine (IEvangelist) commented May 4, 2026 •

Copy link
Copy Markdown
Member Author

Status update — rebased onto main and scope reduced to diagnostic hardening only.

The originally-reported 13.3.0 failure is no longer reproducible after clearing ~/.nuget and ~/.aspire on my machine. The investigation we did in this thread (the 42.42.42.42 ↔ 13.3.0.0 Aspire.TypeSystem skew, the AssemblyRef/AssemblyDef metadata dumps, etc.) was real for the cached state on disk, but the underlying cause was a stale local NuGet cache anomaly — likely from switching between PR / staging / stable 13.3.0 builds — rather than a bug in any shipped build.

So I've:

  1. Re-targeted from release/13.3 to main.
  2. Dropped the IntegrationLoadContext.Load change (the simple-name resolution for Aspire.TypeSystem) and its regression test. Without a confirmed shipped-build failure to defend against, that''s a runtime binding-policy change without a justified payload.
  3. Kept the diagnostic hardening — Warning-level logging on ReflectionTypeLoadException, zero-contributor warnings, the Aspire.TypeSystem version sanity check at startup, error messages that list available languages, and Trace→Debug/Information for apphost-server stdout/stderr.

Net effect: the branch is now a single commit on top of main (ac298d4), 10 files, +530/-9, no behavior change on the success path. PR description updated; #16729 retitled and re-scoped to track the hardening rather than the original 13.3 cache report.

Thanks Eric Erhardt (@eerhardt) for pushing on the binding question — the back-and-forth is what made the "this isn''t a real shipped-build bug" conclusion clear.

David Pine (IEvangelist) and others added 2 commits May 8, 2026 15:53
When `aspire new` is run with a TypeScript template against a CLI bundle whose
`Aspire.TypeSystem` version doesn't match the integration assemblies on disk,
`ReflectionTypeLoadException` thrown by the resolver is swallowed at LogDebug
level and the user sees only:

  No code generator found for language: TypeScript
  No language support found for: typescript/nodejs

This makes the binary mismatch invisible. This change improves the diagnostic
chain at every layer without altering the success path:

* `CodeGeneratorResolver` / `LanguageSupportResolver` now log
  `ReflectionTypeLoadException` at Warning level and include
  `LoaderExceptions` text in the message.
* When an assembly named `Aspire.Hosting.CodeGeneration.*` produces zero
  contributors, log a Warning so the silent-failure case is visible.
* `AssemblyLoader.LoadAssemblies` performs an `Aspire.TypeSystem` version
  sanity check at startup against the libs directory and warns on mismatch.
* `LanguageService` / `CodeGenerationService` error messages now list the
  available languages, or point at the apphost server log + binary mismatch
  when zero are discovered.
* `PrebuiltAppHostServer` promotes apphost-server stdout/stderr capture from
  Trace to Debug/Information, so warnings emitted by the apphost server reach
  the default file log.

Adds `CodeGeneratorResolver.GetSupportedLanguages()` and an internal
test-only constructor on both resolvers that takes a synthetic assembly list,
along with covering tests.

Closes #16729

Co-authored-by: Copilot <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens Aspire’s integration-assembly discovery diagnostics so “no code generator / no language support found” failures become actionable by surfacing type-load failures and likely binary-mismatch scenarios in warnings and in user-facing error messages.

Changes:

  • Promote resolver diagnostics (especially ReflectionTypeLoadException + LoaderExceptions) to Warning, and warn when a codegen assembly contributes zero implementations.
  • Improve LanguageService / CodeGenerationService exceptions to list discovered languages, or point users at “LoaderExceptions” warnings when none are discovered.
  • Add targeted test coverage and a lightweight recording logger to validate the new diagnostic paths.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/Aspire.Hosting.RemoteHost.Tests/ServiceErrorMessageTests.cs Adds tests validating improved user-facing error messages (currently has a constructor-argument mismatch).
tests/Aspire.Hosting.RemoteHost.Tests/ResolverDiagnosticsTests.cs Adds tests asserting Warning diagnostics for type-load failures and zero-contributor assemblies.
tests/Aspire.Hosting.RemoteHost.Tests/RecordingLogger.cs Adds an in-memory ILogger<T> implementation for log assertion in tests.
src/Aspire.Hosting.RemoteHost/Language/LanguageSupportResolver.cs Adds a test seam + warning-level logging for type-load failures and zero contributions.
src/Aspire.Hosting.RemoteHost/Language/LanguageService.cs Improves exception messages with available languages / binary-mismatch guidance.
src/Aspire.Hosting.RemoteHost/IntegrationLoadContext.cs Exposes shared-assembly names for loader sanity checks.
src/Aspire.Hosting.RemoteHost/CodeGeneration/CodeGeneratorResolver.cs Adds a test seam + supported-language enumeration + improved warnings.
src/Aspire.Hosting.RemoteHost/CodeGeneration/CodeGenerationService.cs Improves exception messages with available languages / binary-mismatch guidance.
src/Aspire.Hosting.RemoteHost/AssemblyLoader.cs Adds a startup warning when a shared assembly in libs mismatches the bundled identity.
src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs Raises logging level for apphost server stdout/stderr capture so warnings reach default logs.

Comment on lines +106 to +110
var langResolver = new LanguageSupportResolver(
services,
Array.Empty<Assembly>,
NullLogger<LanguageSupportResolver>.Instance);

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: David Pine <[email protected]>
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.4 milestone May 12, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Harden diagnostics when integration-assembly resolver discovers zero contributors

4 participants