Skip to content

Add SafeUriStjConverter - #7360

Merged
Nigusu-Allehu merged 1 commit into
devfrom
dev-nyenework-stj-safe-uri-converter
May 5, 2026
Merged

Nigusu-Allehu merged 1 commit into
devfrom
dev-nyenework-stj-safe-uri-converter

Conversation

@Nigusu-Allehu

@Nigusu-Allehu Nigusu-Allehu commented May 4, 2026 •

Copy link
Copy Markdown
Member

Bug

Fixes: NuGet/Home#14885
Related: NuGet/Home#14846

Description

This is a focused slice of #7301, split per-converter to make reviewing
easier.

Converters are being migrated first so that the upcoming Registration resource migrations don't become bloated PRs.

SafeUriStjConverter safely deserializes URIs, returning null for invalid or non-string inputs. used by LicenseUrl, ProjectUrl, ReadmeUrl, and AdvisoryUrl.

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.

@Nigusu-Allehu Nigusu-Allehu self-assigned this May 4, 2026
@Nigusu-Allehu
Nigusu-Allehu marked this pull request as ready for review May 4, 2026 00:37
@Nigusu-Allehu
Nigusu-Allehu requested a review from a team as a code owner May 4, 2026 00:37

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.

Pull request overview

Adds a System.Text.Json converter to safely deserialize absolute URIs (returning null for invalid or non-string tokens) as part of the broader NSJ → STJ migration for PackageSearchMetadata-related models.

Changes:

  • Introduce SafeUriStjConverter for tolerant URI deserialization with STJ.
  • Add parity-focused tests comparing STJ behavior with the existing Newtonsoft.Json converter.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/NuGet.Core/NuGet.Protocol/Converters/SafeUriStjConverter.cs Adds the STJ converter that trims and TryCreates absolute URIs, returning null otherwise.
test/NuGet.Core.Tests/NuGet.Protocol.Tests/Converters/SafeUriStjConverterTests.cs Adds tests validating STJ behavior matches the existing NSJ converter across multiple token types.

@Nigusu-Allehu
Nigusu-Allehu merged commit 3f6d5f5 into dev May 5, 2026
21 of 22 checks passed
@Nigusu-Allehu
Nigusu-Allehu deleted the dev-nyenework-stj-safe-uri-converter branch May 5, 2026 22:53
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.

Add System.Text.Json equivalent of SafeUriConverter

4 participants