Skip to content

[Core] HttpRequest.set_text_body makes breaking change to Content-Type header #33751

@mccoyp

Description

@mccoyp

Key Vault SDKs sometimes manipulate request bodies during challenge-based authentication. Specifically, when sending unauthenticated requests to prompt a challenge, the request body is removed. After the challenge is received, the body content is repopulated with the set_text_body method:

request.http_request.set_text_body(body) # no-op when text is None

Today, this code works because KV uses non-DPG code generation; request objects are from azure.core.pipeline.transport instead of azure.core.rest. When DPG is used, requests start to fail because of a breaking change in HttpRequest.set_text_body's behavior: calling the method changes the request's Content-Type header from "application/json" to "text/plain", instead of leaving the header untouched (current behavior).

Recorded tests for azure-keyvault-keys succeed again after DPG generation if

request.http_request.headers["Content-Type"] = "application/json"

is inserted after any calls to set_text_body.

Metadata

Metadata

Labels

Azure.CoreClientThis issue points to a problem in the data-plane of the library.bugThis issue requires a change to an existing behavior in the product in order to be resolved.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions