Skip to content

Report invalid V2 feed responses as a protocol error - #7815

Merged
zivkan merged 1 commit into
NuGet:devfrom
AsadIqbal-Dev:dev-asadiqbal-v2-search-invalid-xml
Oct 29, 2026
Merged

zivkan merged 1 commit into
NuGet:devfrom
AsadIqbal-Dev:dev-asadiqbal-v2-search-invalid-xml

Conversation

@AsadIqbal-Dev

Copy link
Copy Markdown
Contributor

Bug

Fixes: NuGet/Home#14294

Description

dotnet package search against a URL that answers with an HTML page instead of a feed (the Azure DevOps web UI URL in the issue) failed with a raw System.Xml.XmlException, with no mention of the source.

V2FeedParser.LoadXmlAsync(string uri, ...) has two branches. The cached one already wraps any failure in a FatalProtocolException using Log_FailedToFetchV2FeedHttp. The uncached one, which search goes through, parsed the HTTP 200 response with no handling at all. It now catches XmlException and throws the same FatalProtocolException. PackageSearchRunner already catches that per source, so the user gets:

Failed to fetch results from V2 feed at '<url>' with following message : <xml error>

for that source, and results from any other sources are still shown.

Test: new V2FeedParser_Search_WhenSourceReturnsInvalidXml_ThrowsFatalProtocolException serves an HTML page for the search URL. It throws XmlException on dev.

NuGet.Protocol.Tests V2FeedParserTests on net10.0: 26 passed.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

The uncached V2 request path let an XmlException from a non-feed response (such as an HTML page) escape, so package search failed with an unhandled exception. Wrap it in a FatalProtocolException like the cached path does.

Fixes NuGet/Home#14294
@AsadIqbal-Dev
AsadIqbal-Dev requested a review from a team as a code owner October 22, 2026 21:43
@dotnet-policy-service dotnet-policy-service Bot added the Community PRs created by someone not in the NuGet team label Oct 22, 2026
@zivkan
zivkan merged commit cf2ce43 into NuGet:dev Oct 29, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community PRs created by someone not in the NuGet team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stack dump pointing package search at invalid feed

3 participants