Skip to content

Add PowerShell Gallery status message for returned server-side errors - #2084

Open
alerickson wants to merge 6 commits into
masterfrom
cmdletStatus
Open

alerickson wants to merge 6 commits into
masterfrom
cmdletStatus

Conversation

@alerickson

@alerickson alerickson commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

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 PowerShell Gallery may be experiencing an issue. Check https://aka.ms/psgallery for the current service status.

The message appears only for requests to powershellgallery.com or its subdomains. It doesn't appear for other repositories or for other HTTP status codes.

Cmdlets affected

Cmdlet Change
Find-PSResource Search and metadata requests to the Gallery include the status hint after a 5xx error. A failed request now reports only the HTTP error, without an additional XML parse error.
Install-PSResource The package download includes the status hint after a 5xx error. The extra No content was returned by repository and Response returned is null or empty errors no longer appear after a failed download.
Save-PSResource Same as Install-PSResource.
Update-PSResource Same as Install-PSResource.
Publish-PSResource Push failures to the Gallery include the status hint after a 5xx error.

V2 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

…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
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@alerickson

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 thread src/code/Utils.cs
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
@alerickson alerickson changed the title Cmdlet status Add PowerShell Gallery status message for returned server-side errors Nov 10, 2026

This branch has not been deployed

No deployments
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