Skip to content

Conversation

@DarianBaker
Copy link

Add null validation to HttpClientSlim Uri parameters

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Add null validation for Uri parameters in public API methods

Description

This PR adds ArgumentNullException.ThrowIfNull(requestUri) validation to public methods in HttpClientSlim that accept Uri parameters but don't currently validate them.

Methods updated:

  • GetStringAsync(Uri requestUri, bool validateCertificate)
  • PostAsync(Uri requestUri, HttpContent content, bool validateCertificate)
  • GetStream(Uri requestUri, bool validateCertificate) (private helper)
  • GetSocket(Uri requestUri)

Rationale to updating:
Without null validation, callers passing null would receive a NullReferenceException deep in the method implementation. This change provides feedback with ArgumentNullException instead which can improving diagnostics to make the API contract better explicit.

Impact:

  • No breaking changes, only adds validation
  • Better erroring for invalid input
  • Should be consistent with the .NET API design guidelines

@github-actions github-actions bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Jan 24, 2026
@dotnet-policy-service
Copy link
Contributor

Thanks for your PR, @@DarianBaker. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates that the PR has been added by a community member needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant