Skip to content

🔒 Fix the Meta Test build (vulnerable packages + CS9113 in scaffolds) - #631

Merged
AntPolkanov merged 2 commits into
mainfrom
ap/fix-meta-test-build
Jul 27, 2026
Merged

🔒 Fix the Meta Test build (vulnerable packages + CS9113 in scaffolds)#631
AntPolkanov merged 2 commits into
mainfrom
ap/fix-meta-test-build

Conversation

@AntPolkanov

Copy link
Copy Markdown
Member
  1. What triggered this change? (PBI link, Email Subject, conversation + reason, etc)

✏️ The Meta Test workflow has been red on main since #624 (12 Jun), so every PR inherits a failing check - e.g. #630, a docs-only PR. Nothing in those PRs caused it; both problems below are pre-existing on main.

  1. What was changed?

✏️ Two independent problems, both of which only bite in Release because Directory.Build.props sets TreatWarningsAsErrors there.

1. Vulnerable transitive packages (34 restore errors)

NuGet audit turned four packages into NU1902/NU1903 errors, failing restore before compilation:

Package Was Now Advisory
OpenTelemetry.Exporter.OpenTelemetryProtocol 1.15.0 1.15.3 GHSA-4625-4j76-fww9, GHSA-mr8r-92fq-pj8p, GHSA-q834-8qmm-v933
OpenTelemetry.Extensions.Hosting 1.15.0 1.15.3 pulls OpenTelemetry.Api past GHSA-g94r-2vxg-569j
Microsoft.OpenApi 2.0.0 2.7.5 GHSA-v5pm-xwqc-g5wc (high)
MessagePack 2.5.192 2.5.302 GHSA-hv8m-jj95-wg3x + 8 more

Notes on the choices:

  • Microsoft.OpenApi and MessagePack are transitive only (Microsoft.AspNetCore.OpenApiMicrosoft.OpenApi; Aspire.HostingStreamJsonRpcMessagePack). Under CPM a PackageVersion alone does nothing for a transitive package, so each also gets a direct PackageReference - the same workaround already in place for KubernetesClient. Both are marked TODO to remove once upstream bumps.
  • Bumping Microsoft.AspNetCore.OpenApi does not help - even 10.0.10 still declares Microsoft.OpenApi 2.0.0, so Dependabot's #619 would not have fixed this.
  • The OpenTelemetry.Instrumentation.* packages version independently and have no 1.15.3 - bumping them to match produced NU1603. They stay at 1.15.0 and resolve OpenTelemetry.Api to 1.15.3 through the exporter anyway.
  • MessagePack stays on the 2.5 line; 3.x is a major bump that StreamJsonRpc 2.22.23 is not built against.

2. CS9113: Parameter 'dbContext' is unread in the generated scaffolds

Once restore succeeded, Build after a query still failed. The query/command item templates inject IApplicationDbContext dbContext into a handler whose body is throw new NotImplementedException(), so the parameter is never read.

This is a toolchain regression, not a template change - the scaffolds have not changed since #439. Verified by building the same generated file on both SDKs:

SDK 10.0.202 -> CS9113 occurrences: 0
SDK 10.0.302 -> CS9113 occurrences: 2

CI resolves 10.0.302, which is why the last green run was 10 Mar.

CS9113 is suppressed around the scaffolded handler only, rather than added to the global NoWarn list. A template propagates to every downstream consumer, and an unused injected dependency in real code is worth flagging - so the diagnostic stays on everywhere except the stub, where the comment tells the developer to delete the pragmas once they use dbContext.

Test plan

Ran the full Meta Test locally on SDK 10.0.302 (the exact version CI resolves):

Step Before After
Build fresh Project (Debug) 68 warnings 0 warnings, 0 errors
Build after a query (Release) 34 errors 0 warnings, 0 errors
Build after a command (Release) not reached 0 warnings, 0 errors

Also on this branch:

  • dotnet test --configuration Release - 34 domain + 9 architecture + 10 integration tests pass.
  • Confirmed the resolved graph really is patched: Microsoft.OpenApi 2.7.5, MessagePack 2.5.302, OpenTelemetry.Api 1.15.3 across all projects.
  • Pinning Microsoft.OpenApi ahead of the version Microsoft.AspNetCore.OpenApi 10.0.3 was compiled against is the one real runtime risk here, since a break would surface only when the document is generated. MapOpenApi() is unconditional in Program.cs but no test covered it, so I added a temporary integration test hitting /openapi/v1.json - it returned a valid document containing /api/teams. Removed again before committing, though it may be worth adding for real in a follow-up.
  1. Did you do pair or mob programming?

✏️ N/A

AntPolkanov and others added 2 commits July 27, 2026 21:17
NuGet audit flagged four packages, and TreatWarningsAsErrors turns NU1902/NU1903
into errors in Release, so every Release build failed at restore.

- OpenTelemetry exporter/hosting 1.15.0 -> 1.15.3, which also pulls
  OpenTelemetry.Api up to 1.15.3. The Instrumentation.* packages version
  independently and have no 1.15.3, so they stay put.
- Microsoft.OpenApi and MessagePack are transitive only, so each needs a
  direct PackageReference for the pinned version to take effect. Same
  approach already used for KubernetesClient.

Co-authored-by: Claude <noreply@anthropic.com>
The Roslyn shipped in SDK 10.0.3xx reports CS9113 for the scaffold's unread
dbContext parameter (10.0.2xx did not), and TreatWarningsAsErrors turns that
into an error, so the meta test failed as soon as it built a generated query.

Suppressing CS9113 only around the scaffolded handler keeps the diagnostic
active for real code, where an unused injected dependency is worth flagging.

Co-authored-by: Claude <noreply@anthropic.com>
@AntPolkanov
AntPolkanov marked this pull request as ready for review July 27, 2026 11:33
@AntPolkanov
AntPolkanov requested a review from danielmackay July 27, 2026 11:33
@AntPolkanov
AntPolkanov enabled auto-merge (squash) July 27, 2026 11:41
@AntPolkanov
AntPolkanov merged commit 9d2aa7c into main Jul 27, 2026
2 checks passed
@AntPolkanov
AntPolkanov deleted the ap/fix-meta-test-build branch July 27, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants