Repository navigation
Tolerate NuGet credential-provider stdout preamble in package search parsing - #19343
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 19343Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 19343" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Centralizes tolerance for NuGet credential-provider stdout preambles so package searches continue parsing valid JSON.
Changes:
- Extracts JSON beginning at the first object token.
- Applies extraction to standard and bundled package searches.
- Adds regression coverage for both paths.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Shared/PackageUpdateHelpers.cs |
Adds shared JSON payload extraction. |
src/Aspire.Cli/NuGet/BundleNuGetPackageCache.cs |
Handles preambles in bundled searches. |
tests/Aspire.Hosting.Tests/VersionChecking/PackageUpdateHelpersTests.cs |
Tests standard search parsing. |
tests/Aspire.Cli.Tests/NuGet/BundleNuGetPackageCacheTests.cs |
Tests bundled search parsing. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
PR Testing ReportPR Information
Artifact Version Verification
Changes AnalyzedFiles Changed
Change Categories
Test Scenarios ExecutedScenario 1: PR artifact identityObjective: Verify the tested CLI artifact was built from the latest PR commit. Coverage Type: Artifact verification Status: PASS Steps:
Evidence:
Observations:
Scenario 2: Focused parser regression testsObjective: Validate both changed parsing paths against credential-provider preamble output and existing clean/empty payload behavior. Coverage Type: Happy path and boundary regression Status: PASS Steps:
Evidence:
Observations:
Scenario 3: Installed CLI package-search and add flowObjective: Exercise the changed bundled package-search parser through a real Coverage Type: User-facing happy path Status: PASS Steps:
Evidence:
Observations:
Scenario 4: AppHost version-check runtime pathObjective: Verify the shared parser works during a real AppHost version check and does not emit JSON parsing failures. Coverage Type: Runtime happy path and safe shutdown Status: PASS Steps:
Evidence:
Observations:
Scenario 5: Live stdout shape probeObjective: Determine whether this host reproduces credential-provider stdout pollution outside the synthetic fixtures. Coverage Type: Environment-specific boundary probe Status: PASS with limitation Steps:
Evidence:
Observations:
Summary
Overall ResultPR VERIFIED The latest PR artifact and exact source commit passed all planned scenarios. Both affected parser paths accept the credential-provider preamble fixture while preserving clean and empty-result behavior. Real installed-CLI package discovery, Recommendations
|
Adam Ratzman (adamint)
left a comment
There was a problem hiding this comment.
Two parser edge cases still reproduce the original package-search failure: provider output can contain a { before the payload, and provider stdout can trail the payload. I left both inline. The intended preamble path and clean JSON path work, the focused tests pass, and a process-level CLI shim verified the real command path. Holding approval because auto-merge is enabled and I think these should be fixed first.
…parsing dotnet package search --format json can emit non-JSON [CredentialProvider] progress lines to stdout before the JSON payload (exit code still 0) when an authenticated Azure DevOps / Azure Artifacts feed is configured. Parsing the whole stdout as JSON then throws a JsonReaderException, silently breaking the background version check (stack logged every run) and causing aspire add / integration search to report no packages. Add a shared PackageUpdateHelpers.ExtractJsonPayload helper that skips the preamble by starting at the first brace, and use it in ParsePackageSearchResults (version check + CLI live/disk-cache search paths) and BundleNuGetPackageCache (aspire-managed bundle search path). Clean JSON and genuinely empty/malformed output are unchanged. Fixes #19339 Co-authored-by: Copilot App <[email protected]> Copilot-Session: 8e466090-81d0-4e48-8423-daf6eea6fdc3
Scan complete JSON object candidates, validate the expected package-search shape, and return only the consumed value so diagnostic JSON before the result and provider output after it cannot corrupt parsing. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 8e466090-81d0-4e48-8423-daf6eea6fdc3
3e63fc2 to
bdcb171
Compare
This comment has been minimized.
This comment has been minimized.
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Cover empty results, UTF-8 diagnostics, incomplete root-level near matches, and missing payloads. Let each caller validate its concrete JSON contract so incomplete diagnostic objects are skipped before parsing. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 8e466090-81d0-4e48-8423-daf6eea6fdc3
Tests selector (audit mode)The full test matrix and all jobs still run in audit mode. The tests and jobs below are what selective CI would run under enforcement. 50 / 100 test projects · 5 jobs, from 4 changed files. Selected test projects (50 / 100)
Selected jobs (5)
How these were chosen — grouped by what changed
🔧 show 43
🧪 📦 affected project 📦 affected project 🧪 Job reasons
Selection computed for commit |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Adam Ratzman (adamint)
left a comment
There was a problem hiding this comment.
The parser changes look good. I verified the two earlier concerns are addressed: it scans complete JSON values instead of trusting the first brace, and it returns only the consumed payload when provider output follows the JSON. The focused CLI/Hosting tests passed, along with a direct 20-case parser harness covering glued preambles, suffixes, malformed input, UTF-8 offsets and both payload schemas.
This comment has been minimized.
This comment has been minimized.
|
✅ No documentation update needed. Step 5 branch taken: Triggered signals (1): Why this is a false positive: |
Description
dotnet package search <id> --format jsonis parsed as if its entire stdout were a single JSON document. When an authenticated Azure DevOps / Azure Artifacts feed is configured, the NuGet Azure Artifacts Credential Provider writes[CredentialProvider]…progress lines to stdout before the JSON payload while the command still exits0. Parsing the whole stdout then throws:Example polluted stdout (JSON begins after the preamble; stderr empty; exit code 0):
Impact: the background version check is silently broken (a
JsonReaderExceptionis logged everyaspire runand no upgrade prompts appear), and CLI package operations (aspire add) can report "no packages found" — affecting essentially every developer with an authenticated Azure DevOps feed.Fix: add a small, well-documented shared helper
PackageUpdateHelpers.ExtractJsonPayloadthat skips the non-JSON preamble by starting at the first{, and apply it everywheredotnet package search(and the bundleaspire-managedsearch) stdout is parsed:PackageFetcher.TryFetchPackagesAsync→ParsePackageSearchResults.DotNetCliRunner.SearchPackagesAsync, both the live parse and the disk-cache read →ParsePackageSearchResults.BundleNuGetPackageCachedeserializes theaspire-managedhelper stdout directly.Clean JSON (no preamble) and genuinely empty/malformed output (no
{) are returned unchanged, so existingJsonExceptionhandling is preserved. This matches the direction validated by the issue author ("Isolating from the first{parses the captured output cleanly").Fixes #19339
Checklist
<remarks />and<code />elements on your triple slash comments?