Skip to content

[CRED-2625] Re-apply Authorization header redaction in debug logRequest#4208

Closed
luczhou wants to merge 1 commit into
masterfrom
lucinda.zhou/CRED-2625/restore-authorization-redaction
Closed

[CRED-2625] Re-apply Authorization header redaction in debug logRequest#4208
luczhou wants to merge 1 commit into
masterfrom
lucinda.zhou/CRED-2625/restore-authorization-redaction

Conversation

@luczhou
Copy link
Copy Markdown
Contributor

@luczhou luczhou commented May 19, 2026

Description

Re-applies the fix from #4168 that was reverted by #4207. The original revert was a misdirected unblock: the test was failing on a separate, regen-only branch where the production-code edit had been silently stripped out by the spec-sync regen, while the new test file persisted. That looked like a broken fix; it was actually a template-vs-generated-file mismatch.

Investigation summary:

A companion patch against datadog-api-client-generator updates both templates so this fix is durable. Once that lands, the next regen reproduces the generated file in this PR byte-for-byte.

Changes

  • packages/datadog-api-client-common/http/isomorphic-fetch.ts: restores the headersToRedact array (DD-API-KEY, DD-APPLICATION-KEY, Authorization) and the loop that masks each value with x repeated to its original length.
  • tests/api/log-redaction.test.ts: restored. Drives logRequest directly with a captured logger.debug, asserts the raw bearer string does not appear in the joined output, and asserts Authorization is masked to an x+ run.

Cross-language status

Testing

Tracking ticket: CRED-2625. Surfaced in terraform-provider-datadog#3757.

🤖 Generated with Claude Code

This reverts commit 6954a1cd5d2a3d2b9f9a8e3f4d5c6b7a8f9e0d1c
(#4207), which itself reverted the original fix in #4168.

The revert was prompted by a failing test on the auto-generated
spec-sync PR #4156 (branch `datadog-api-spec/generated/5684`). At
the time of that failure the branch contained the test from #4168
but not the production-code edit from #4168. That looked like the
redaction was broken; it actually meant `isomorphic-fetch.ts` is
template-managed.

The template lives in a separate repo,
`DataDog/datadog-api-client-generator`, under both:
- `src/.../typescript/templates/common_package/http/isomorphic-fetch.ts.j2`
- `src/.../typescript_unified/templates/http/isomorphic-fetch.ts.j2`

The original PR #4168 edited the generated file but never touched
the templates, so the next `api-clients-generation-pipeline[bot]`
regen rewrote `isomorphic-fetch.ts` from template — silently
deleting the redaction. The split-diff branch state (test present,
production code reverted) then failed the redaction assertion, and
the revert was applied as an unblock instead of root-causing the
template gap.

A companion PR against `datadog-api-client-generator` adds the
Authorization redaction to both templates so this fix is durable.
Once both land, the next regen reproduces this generated file
unchanged.

Restores:
- `packages/datadog-api-client-common/http/isomorphic-fetch.ts`:
  adds Authorization to the `headersToRedact` list alongside
  DD-API-KEY / DD-APPLICATION-KEY, preserving the existing
  per-character `x` mask.
- `tests/api/log-redaction.test.ts`: asserts the raw bearer token
  does not appear anywhere in the joined debug-log output and that
  Authorization is masked to an `x+` run.

Tracking ticket: CRED-2625. Surfaced in
terraform-provider-datadog#3757 (the first Terraform code path that
sets ContextAccessToken).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@luczhou luczhou closed this May 22, 2026
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.

1 participant