Redact outgoing path when route is unknown - #7687
Open
Rimobul wants to merge 1 commit into
Open
Conversation
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".
Contributor
There was a problem hiding this comment.
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.GetRedactedPathAndParametersto returnREDACTEDwhen bothRequestRouteandRequestNameare"unknown". - Convert the existing test to a theory to cover both default and non-default
DependencyNamewhile asserting the path isREDACTED. - Add a regression test for the
HttpDependencyMetadataResolverhost-default metadata case (host matched, route not matched) to ensure the path isREDACTED.
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. |
evgenyfedorov2
approved these changes
Aug 7, 2026
| public async Task ReadAsync_MetadataWithoutRequestRouteOrNameUsesConstants_ReturnsLogRecord() | ||
| [Theory] | ||
| [InlineData(TelemetryConstants.Unknown)] | ||
| [InlineData("Graph")] |
Member
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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