Skip to content

Conversation

@m-redding
Copy link
Member

@m-redding m-redding commented Dec 9, 2025

Some libraries set filepaths as filenames in multipart/form-data Content-Disposition headers, which is okay according to the HTTP spec. This caused issues in the test proxy which does a byte comparison. It will only succeed if the test was recorded and played back on the same OS. I added a sanitizer to normalize this in Azure/azure-sdk-tools#12948

This adds a custom sanitizers list and regenerates to include the new sanitizer. It also adds a boolean to remove default sanitizers except for the Authorization header sanitizer. For OpenAI, the only default sanitizer needed is the Authorization header. All of the unused default sanitizers are causing a huge performance bottleneck when working with large Audio/Image requests

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

Microsoft.ClientModel.TestFramework

@m-redding m-redding changed the title [Microsoft.ClientModel.TestFramework] Add ability to turn on content disposition filepath normalization in the test proxy core/testframework: update API listings with .NET and add ability to turn on content disposition filepath normalization in the test proxy Dec 9, 2025
@m-redding m-redding changed the title core/testframework: update API listings with .NET and add ability to turn on content disposition filepath normalization in the test proxy Add ability to turn on content disposition filepath normalization in the test proxy Dec 9, 2025
@m-redding m-redding changed the title Add ability to turn on content disposition filepath normalization in the test proxy [Microsoft.ClientModel.TestFramework] Add ability to turn on content disposition filepath normalization in the test proxy Dec 9, 2025
@m-redding m-redding changed the title [Microsoft.ClientModel.TestFramework] Add ability to turn on content disposition filepath normalization in the test proxy [Microsoft.ClientModel.TestFramework] Add ability to turn on content disposition filepath normalization in the test proxy and remove default sanitizers Dec 12, 2025
@m-redding m-redding changed the title [Microsoft.ClientModel.TestFramework] Add ability to turn on content disposition filepath normalization in the test proxy and remove default sanitizers [Microsoft.ClientModel.TestFramework] content disposition filepath normalization and remove default sanitizers Dec 12, 2025
@m-redding m-redding changed the title [Microsoft.ClientModel.TestFramework] content disposition filepath normalization and remove default sanitizers [Microsoft.ClientModel.TestFramework] add options for content disposition filepath normalization and removing default sanitizers Dec 12, 2025
@m-redding m-redding marked this pull request as ready for review December 17, 2025 00:34
@m-redding m-redding requested a review from a team as a code owner December 17, 2025 00:34
Copilot AI review requested due to automatic review settings December 17, 2025 00:34
Copy link
Contributor

Copilot AI left a comment

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 enhances the test framework with two key features to address cross-platform recording compatibility and performance issues. It adds a ContentDispositionFilePathSanitizer to normalize file paths in Content-Disposition headers (preventing OS-specific recording failures), and introduces a RemoveDefaultSanitizers option to improve performance for large request bodies by allowing selective sanitizer removal while preserving the Authorization header sanitizer.

Key changes:

  • Adds RemoveDefaultSanitizers boolean property and CustomSanitizers list to RecordedTestBase
  • Implements logic in TestRecording to remove default sanitizers except AZSDK0000 (Authorization)
  • Introduces ContentDispositionFilePathSanitizer model and enum value
  • Regenerates client code with test-proxy version 1.0.0-dev.20251209.1, including various serialization and infrastructure improvements

Reviewed changes

Copilot reviewed 11 out of 65 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
RecordedTestBase.cs Adds RemoveDefaultSanitizers property and CustomSanitizers list for test configuration
TestRecording.cs Implements removal of hardcoded list of default sanitizers and applies custom sanitizers
RemoveDefaultSanitizersTests.cs Tests that default sanitizers are removed except Authorization header sanitizer
MapsClientTests.cs Tests default behavior and adds ContentDispositionFilePathSanitizer to CustomSanitizers
ContentDispositionFilePathSanitizer.cs New generated model for the Content-Disposition filepath sanitizer
SanitizerType.cs/Serialization.cs Adds ContentDispositionFilePathSanitizer enum value and serialization
SanitizerAddition.cs/Serialization.cs Updates documentation to include new sanitizer type
TestProxyClient*.cs Regenerated with updated SDK patterns (cancellation token handling, pipeline message creation)
TestProxyAdminClient*.cs Regenerated with consistent patterns for request options
Various Serialization files Updates JsonDocument.Parse calls to use JsonDocumentOptions for consistency
TypeFormatters.cs Refactors to use SerializationFormat enum instead of string format specifiers
ClientUriBuilder.cs Optimizes by consolidating path and query into single StringBuilder
SerializationFormat.cs New enum defining serialization format options
CancellationTokenExtensions.cs New extension method for converting CancellationToken to RequestOptions
CodeGen*Attribute.cs Changes namespace to Microsoft.TypeSpec.Generator.Customizations
assets.json Updates assets tag for new test recordings
.config/dotnet-tools.json Updates test-proxy version to 1.0.0-dev.20251209.1
API surface files (*.cs) Updates public API surface to expose new properties and sanitizer type

@m-redding m-redding merged commit fa0138f into Azure:main Dec 17, 2025
41 checks passed
@m-redding m-redding deleted the testframework-multipart branch December 17, 2025 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants