Skip to content

Report why Pip's PyPI version lookups fail - #5791

Merged
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
pip-lookup-failure-reason
Nov 18, 2026
Merged

Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
pip-lookup-failure-reason

Conversation

@GabrielDuf

@GabrielDuf Gabriel Dufresne (GabrielDuf) commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Related to #5787

Problem

When Pip's in-process update check cannot resolve a package against pypi.org, the exception is only written with Logger.Debug, which never reaches user logs. The Manager statuses page and the task log only say 1 of 1 version lookups against https://pypi.org/ failed, the update list would be incomplete, with no cause.

In #5787 every check hangs for the 20 second client timeout while pip itself works from a terminal, and the logs give nothing to tell a connection timeout from a TLS or DNS failure.

Change

  • VersionResolution carries the failure's exception chain (DescribeFailure: type and message of every inner exception).
  • GetAvailableUpdatesFromIndex writes each failed lookup's reason to the Pip task log.
  • The exception raised when too many lookups fail ends with First failure: <package>: <reason>, so it shows on Manager statuses too.

No behaviour change otherwise: the same lookups run, and the same threshold decides whether the check fails.

This does not fix #5787 itself; it is meant to show the actual cause in the reporter's next log.

Tests

  • ResolveLatestVersionReportsWhyALookupFailed: a stalled handler with a 200 ms HttpClient.Timeout yields a failure whose reason names the timeout.
  • DescribeFailureIncludesEveryInnerException.
  • PipManagerTests: 72/72 passed. dotnet format whitespace and dotnet format style both exit 0.

When the in-process update check could not resolve a package against
pypi.org, the exception was only written with Logger.Debug, which never
reaches user logs. Users saw "1 of 1 version lookups against
https://pypi.org/ failed" with no cause, so a report like #5787 (every
check hanging for the 20 second client timeout while pip itself works
from a terminal) could not be diagnosed.

Each failed resolution now carries its exception chain. It is written
to the Pip task log for every package, and the first one is appended to
the error raised when too many lookups fail, so it shows on the Manager
statuses page as well.

Related to #5787

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Cached-version fallbacks still hide request failures, and cancellation diagnostics do not identify when the 45-second budget is exhausted.

2 open issues
What changed in this PR

Improves diagnostics for Pip’s in-process PyPI update checks to help investigate #5787. The change exposes failure causes without changing lookup behavior or the existing failure threshold; it does not fix the underlying connectivity issue.

Changes:

  • Carries exception types and messages through version-resolution results.
  • Adds per-package failure reasons to task logs and the first failure to the manager-status exception.
  • Adds tests for timeout diagnostics and nested exception formatting.
File Description
src/​UniGetUI.PackageEngine.Tests/​PipManagerTests.cs Adds timeout and exception-chain diagnostic tests.
src/​UniGetUI.PackageEngine.Managers.Pip/​Pip.cs Captures lookup failure details and includes them in logs and status errors.

Review effort: Balanced

When the 45 second resolution budget cancelled a lookup, the recorded
reason was only "The operation was canceled.", which does not say that
the overall check ran out of time. A lookup cancelled while its budget
token is set now says so, ahead of the original exception chain.

A lookup that failed for a package with a cached version returned that
version before its reason was kept, so a failed refresh left nothing in
the task log. The reason now travels with the cached result and is
logged as information. Failed stays false there, so the failure
threshold and the cached-result behaviour are unchanged.

Related to #5787

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Cached lookup failures remain invisible in the normal manager log and do not produce a manager-status error.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Log cached lookup failures in the normal manager log

src/​UniGetUI.PackageEngine.Managers.Pip/​Pip.cs:919

The normal manager log hides NativeTaskLogger's information stream (AsColoredString(false) shows only ...), so a cached lookup failure is still invisible there unless the user selects the verbose log. Since this path also keeps Failed false, it produces no manager-status error either. Please write the refresh failure to a channel visible in the normal log while retaining the cached-result behavior.

2 resolved since last review

Review effort: Balanced

@randy-but-a-ro randy-but-a-ro Bot 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.

🤖 Pull request was approved automatically: the AI review is complete and all its review threads are resolved. 🎉

Integration Details
{
	"deliveryId": "ef897c50-e35b-11f1-90d9-1f803e630489",
	"headSha": "d6100e5c2e630cb85fef033215dbc53b5fd1fd39",
	"reviewer": "copilot-pull-request-reviewer[bot]"
}

@GabrielDuf
Gabriel Dufresne (GabrielDuf) merged commit 63f74bc into main Nov 18, 2026
10 checks passed
@GabrielDuf
Gabriel Dufresne (GabrielDuf) deleted the pip-lookup-failure-reason branch November 18, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working pip

2 participants