Repository navigation
Add PowerShell Gallery status message for returned server-side errors - #2084
Open
alerickson wants to merge 6 commits into
Open
alerickson wants to merge 6 commits into
alerickson wants to merge 6 commits into
Conversation
…uest fails with a 404 or 5xx, add a manual Test-PSGalleryOutage.ps1 script to simulate gallery outages
…a an explicit return value instead of the shared error count, and add tests for the PowerShell Gallery status hint
…into cmdletStatus
alerickson
requested review from
Sydney Smith (SydneyhSmith),
Aditya Patwardhan (adityapatwardhan),
Anam Navied (anamnavi) and
shammu1
as code owners
November 10, 2026 01:41
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Member
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
🟡 Changes recommended
The outage test can leave the hosts file modified when it lacks a trailing newline, and Gallery 503 detection relies on English exception text, omitting status hints on localized .NET Framework installations.
2 open issues
What changed in this PR
This PR improves PSResourceGet error reporting by adding a PowerShell Gallery service-status link for Gallery HTTP 5xx failures and suppressing redundant follow-up errors.
Changes:
- Adds shared status-hint helpers for V2 requests and publishing failures.
- Avoids secondary parse, not-found, and empty-content errors after request failures.
- Adds automated hint tests and a manual Gallery-outage simulator.
| File | Description |
|---|---|
test/Test-PSGalleryOutage.ps1 |
Simulates Gallery failures for manual cmdlet validation. |
test/PublishPSResourceTests/PublishPSResource.Tests.ps1 |
Adds Gallery status-hint tests. |
src/code/V2ServerAPICalls.cs |
Adds status hints and suppresses redundant request-failure errors. |
src/code/Utils.cs |
Adds Gallery detection and status-message helpers. |
src/code/PublishHelper.cs |
Appends status hints to publishing errors. |
src/code/FindHelper.cs |
Skips response processing after reported request errors. |
Review effort: Balanced
Comment on lines
+259
to
+260
| Match match = Regex.Match(exceptionMessage, @"status code does not indicate success: (\d{3})", RegexOptions.IgnoreCase); | ||
| return match.Success ? GetPSGalleryStatusMessage(uri, (HttpStatusCode)int.Parse(match.Groups[1].Value)) : string.Empty; |
|
|
||
| try { | ||
| if (-not $SkipHostsFile) { | ||
| Add-Content -Path $hostsFile -Value $hostsLine |
This branch has not been deployed
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.

PR Summary
When a request to the PowerShell Gallery fails with an HTTP 5xx server error, these cmdlets now add the following message to the error:
The message appears only for requests to
powershellgallery.comor its subdomains. It doesn't appear for other repositories or for other HTTP status codes.Cmdlets affected
Find-PSResourceInstall-PSResourceNo content was returned by repositoryandResponse returned is null or emptyerrors no longer appear after a failed download.Save-PSResourceInstall-PSResource.Update-PSResourceInstall-PSResource.Publish-PSResourceV2 request errors also show the full HTTP error details, including the request URL, status code, and Gallery hint, in the main error message. Before, these details were wrapped in an inner exception that PowerShell doesn't show by default.
PR Context
During a Gallery outage, users can see several unclear errors that don't identify the Gallery as the cause. They may then troubleshoot their own configuration or open issues against PSResourceGet. Pointing them to the Gallery status page and reporting one clear error for each failed request makes it easier to recognize a service-side outage.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.