Repository navigation
Surface silent integration-assembly load failures (#16729) - #16733
David Pine (IEvangelist) wants to merge 3 commits into
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16733Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16733" |
|
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? |
|
Status update — rebased onto The originally-reported So I've:
Net effect: the branch is now a single commit on top of 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. |
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]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
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) toWarning, and warn when a codegen assembly contributes zero implementations. - Improve
LanguageService/CodeGenerationServiceexceptions 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. |
| 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]>
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:
The original report (#16729) was a cryptic CLI failure on
aspire newwith 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 / stable13.3.0builds) and is not reproducible after clearing~/.nugetand~/.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/LanguageSupportResolvernow logReflectionTypeLoadExceptionat Warning level and include theLoaderExceptionstext in the message (was previouslyLogDebug, which is below the file logger''s default Information threshold and never reached the user log).Aspire.Hosting.CodeGeneration.*is loaded but contributes zeroICodeGenerator/ILanguageSupporttypes, log a Warning so the silent-failure case is visible.AssemblyLoader.LoadAssembliesperforms anAspire.TypeSystemversion 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/CodeGenerationServiceerror messages now list the available languages, or point at the apphost-server log + binary mismatch when zero are discovered.PrebuiltAppHostServerpromotes spawned-process stdout/stderr capture fromTracetoDebug/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.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 onReflectionTypeLoadException.ServiceErrorMessageTests(4) — proves the user-visible error messages list available languages or point at the binary-mismatch scenario.All
Aspire.Hosting.RemoteHost.Testspass locally.Notes
release/13.3tomain. The branch was reset toupstream/mainand the diagnostic commit was cherry-picked clean.IntegrationLoadContext.Loadchange that resolvedAspire.TypeSystemby simple name from the default ALC, intended to tolerate42.42.42.42↔13.3.0.0version 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
ResolverDiagnosticsTests(4) andServiceErrorMessageTests(4) covering the new diagnostic paths.CodeGeneratorResolver.GetSupportedLanguages(), the additional resolver constructors, andIntegrationLoadContext.GetSharedAssemblyNames()are allinternal; the resolvers themselves areinternal sealed.