Skip to content

Commit 183f5a9

Browse files
Copilotheaths
andauthored
Add azure-deprecating to default allowed headers for logging
Add `azure-deprecating` to the default set of response headers that are logged without redaction in the Azure Core HTTP pipeline sanitizer. The `azure-deprecating` header is used per the Azure API Guidelines deprecating behavior notification guidance to notify clients about upcoming API deprecations. Without this change, the header value would be logged as REDACTED, hiding important deprecation warnings. - Add azure-deprecating to defaultAllowedHeaderNames in sanitizer.ts - Update sdk/core/logger/README.md to keep the documented list in sync - Add test verifying azure-deprecating is not redacted - Update ts-http-runtime CHANGELOG Co-authored-by: heaths <1532486+heaths@users.noreply.github.com>
1 parent d749832 commit 183f5a9

4 files changed

Lines changed: 25 additions & 0 deletions

File tree

sdk/core/logger/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Request and response bodies are never logged. Headers are redacted by default, u
5151
- "ms-cv",
5252
- "return-client-request-id",
5353
- "traceparent",
54+
- "azure-deprecating",
5455
- "Access-Control-Allow-Credentials",
5556
- "Access-Control-Allow-Headers",
5657
- "Access-Control-Allow-Methods",

sdk/core/ts-http-runtime/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### Features Added
66

7+
- `azure-deprecating` response header is now included in the default set of headers logged without redaction. See [Azure API Guidelines: Deprecating Behavior Notification](https://github.com/microsoft/api-guidelines/blob/vNext/azure/Guidelines.md#deprecating-behavior-notification) for more information.
8+
79
### Breaking Changes
810

911
### Bugs Fixed

sdk/core/ts-http-runtime/src/util/sanitizer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const defaultAllowedHeaderNames = [
3535
"ms-cv",
3636
"return-client-request-id",
3737
"traceparent",
38+
"azure-deprecating",
3839

3940
"Access-Control-Allow-Credentials",
4041
"Access-Control-Allow-Headers",

sdk/core/ts-http-runtime/test/internal/logPolicy.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,25 @@ describe("logPolicy", function () {
4040
assert.notInclude(headersLog!, "secret-value");
4141
assert.include(headersLog!, "REDACTED");
4242
});
43+
44+
it("Does not redact the azure-deprecating response header", async function () {
45+
const { logger, logs } = createTestLogger();
46+
const policy = logPolicy({ logger });
47+
48+
const request = createPipelineRequest({ url: "https://example.com" });
49+
const responseHeaders = createHttpHeaders({
50+
"azure-deprecating": "This API version will be retired on 2025-01-01",
51+
});
52+
53+
await policy.sendRequest(request, async (req) => ({
54+
request: req,
55+
status: 200,
56+
headers: responseHeaders,
57+
}));
58+
59+
const headersLog = logs.find((log) => log.startsWith("Headers:"));
60+
assert.isDefined(headersLog);
61+
assert.include(headersLog!, "This API version will be retired on 2025-01-01");
62+
assert.notInclude(headersLog!, "REDACTED");
63+
});
4364
});

0 commit comments

Comments
 (0)