Skip to content

Redact outgoing path when route is unknown - #7687

Open
Rimobul wants to merge 1 commit into
dotnet:mainfrom
Rimobul:lsokolovsky/issue-7536
Open

Redact outgoing path when route is unknown#7687
Rimobul wants to merge 1 commit into
dotnet:mainfrom
Rimobul:lsokolovsky/issue-7536

Conversation

@Rimobul

@Rimobul Rimobul commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #7536

HttpRequestReader logged path="unknown" when RequestMetadata was attached but RequestRoute and RequestName were left at their defaults. The no-metadata branch already returns "REDACTED" for the same situation, so both cases now converge on "REDACTED".

Microsoft Reviewers: Open in CodeFlow

Fixes dotnet#7536

HttpRequestReader logged path="unknown" when RequestMetadata was
attached but RequestRoute and RequestName were left at their defaults.
The no-metadata branch already returns "REDACTED" for the same
situation, so both cases now converge on "REDACTED".
@Rimobul
Rimobul requested a review from a team as a code owner August 7, 2026 14:01
Copilot AI review requested due to automatic review settings August 7, 2026 14:01

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

This PR fixes outgoing HTTP logging so that when RequestMetadata is present but both RequestRoute and RequestName are left at their default (TelemetryConstants.Unknown), the logged Path is conservatively scrubbed to TelemetryConstants.Redacted—matching the existing behavior when no metadata is attached.

Changes:

  • Update HttpRequestReader.GetRedactedPathAndParameters to return REDACTED when both RequestRoute and RequestName are "unknown".
  • Convert the existing test to a theory to cover both default and non-default DependencyName while asserting the path is REDACTED.
  • Add a regression test for the HttpDependencyMetadataResolver host-default metadata case (host matched, route not matched) to ensure the path is REDACTED.

Reviewed changes

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

File Description
test/Libraries/Microsoft.Extensions.Http.Diagnostics.Tests/Logging/HttpRequestReaderTest.cs Updates/extends coverage to assert Path becomes TelemetryConstants.Redacted when metadata exists but route/name are defaults, including resolver host-default behavior.
src/Libraries/Microsoft.Extensions.Http.Diagnostics/Logging/Internal/HttpRequestReader.cs Adjusts the unknown-route branch to emit TelemetryConstants.Redacted when RequestName is also unknown.

public async Task ReadAsync_MetadataWithoutRequestRouteOrNameUsesConstants_ReturnsLogRecord()
[Theory]
[InlineData(TelemetryConstants.Unknown)]
[InlineData("Graph")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't see why we need to turn it into a Theory, different dependencyName values do not seem to affect the test logic nor results

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.

HttpClient outgoing logging: default-filled RequestMetadata yields path="unknown" instead of "REDACTED"

3 participants