Repository navigation
Report every unresolvable SDK package, not just the first - #28
Merged
Merged
Conversation
$ErrorActionPreference is Stop in update-sdks.ps1, which makes a bare Write-Error terminating. The two Write-Error calls in the resolution loop were not wrapped, so the first unresolvable package threw straight out of the script and the `continue` beneath each one was dead code. A maintainer saw one failure per run: fix it, rerun, discover the next. Failures are now named on the error stream as they happen and collected, and the run fails once after every package has been looked at. The throw stays ahead of the write phase, so a run that could not resolve part of the family does not converge the rest and leave the repository on two versions of the same SDK -- the partially applied state this script exists to repair. Two test cases cover the path, which had none: every case in the suite passed -Version explicitly, which skips Get-LatestReleasedVersion entirely. Neither touches the network -- one points at a closed port, the other at an in-process HttpListener stub that provokes both failure branches at once. Fixes #27 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012betVHk3gFcj5RYkEe4vrm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #27
The defect
scripts/update-sdks.ps1sets$ErrorActionPreference = 'Stop'at line 54, which makes a bareWrite-Errorterminating. NeitherWrite-Errorin the resolution loop was wrapped in atry/catch, so the first unresolvable package threw straight out of the script and thecontinuebeneath each one was dead code.Measured at
main(ea3d28a), PowerShell 7.4.6 on Linux, against a fixture pinning three packages and a closed port as the feed:ktsu.Sdk.Appandktsu.Sdk.Toolare never attempted. Because the loop runsGroup-Object Name | Sort-Object Name, whichever package sorts first decides how much of the run happens at all — andktsu.Sdk, the package nearly every repository pins, sorts first.The change
Failures are named on the error stream as they happen —
-ErrorAction Continue, which is the explicit form of what thecontinuewas already trying to express — and collected into$failed. The run then fails once, after every package has been looked at:The throw stays ahead of the write phase. That placement is the part worth arguing about, because reporting the failures and converging the packages that did resolve looks like the more helpful behaviour. It is not: it would leave
global.jsonon 2.29.0 for one member of the family and 1.0.0 for the rest — two versions of the same SDK in one repository, which is the exact state this script exists to repair, and whichdocs/sdk-pinning.mdalready commits to avoiding ("A failure leaves the repository untouched and red"). All-or-nothing is preserved; only the reporting changes.The issue also notes that the run "never gets to report which references are stale for packages that did resolve successfully". That is left alone deliberately — a staleness report computed from a partial set of targets would read as a complete one, and the failure is the actionable output.
Tests
The resolution path had no coverage at all: every existing case passes
-Versionexplicitly, which skipsGet-LatestReleasedVersionentirely. Two cases added, neither touching the network.every unresolvable package is reported, not just the first127.0.0.1:9)catchbranch; the defect itselfa resolvable package neither hides a failure nor is written past oneHttpListenerstubThe second case is the interesting one.
ktsu.Sdkresolves to 2.29.0 while the fixture pins 1.0.0,ktsu.Sdk.App404s (thecatchbranch) andktsu.Sdk.Toolpublishes only a prerelease (the-not $latestbranch). It asserts both failures are named and thatglobal.jsonis untouched, so a fix that reported-and-carried-on fails it even though it would pass the first case.The stub feed is ~40 lines of
Start-StubFeed/Stop-StubFeedusingHttpListeneron aStart-ThreadJob.Invoke-RestMethodrejectsfile://("The 'file' scheme is not supported"), so a static fixture directory is not an option and a real HTTP endpoint is the only way to reach the-not $latestbranch. It binds the first free port in 18080–18179 and answers an unmapped package id with 404.Proved failing without the fix. Reverting only
scripts/update-sdks.ps1and keeping both tests:Both fail on the right thing — the packages the run never reached — rather than on a message that merely changed shape. The 7 pre-existing cases are unaffected in both directions.
Verification
scripts/tests/update-sdks.tests.ps1— 9 of 9 passed, exit 0update-sdks.ps1— 2 of 9 failed, exit 1, as abovemarkdownlint docs/sdk-pinning.md— cleanRun on PowerShell 7.4.6 on Linux. Worth recording for the next run in this container:
pwshis not installed anddotnet tool installis broken here for every package, the same limitation recorded on ktsu-dev/Sdk#34 and on #26. The official tarball from the PowerShell GitHub releases works and is what I used.Docs
docs/sdk-pinning.mdgains a paragraph stating the behaviour and why the run fails before writing rather than converging what it can. It sits next to the existing "A failure leaves the repository untouched and red" sentence, which this makes true of the multi-package case too.🤖 Generated with Claude Code
https://claude.ai/code/session_012betVHk3gFcj5RYkEe4vrm
Generated by Claude Code