Skip to content

fix(javascript): mask API key in ApiError stack trace - #7182

Merged
Fluf22 merged 1 commit into
mainfrom
fix/javascript-mask-api-key-stack-trace
Oct 23, 2026
Merged

Fluf22 merged 1 commit into
mainfrom
fix/javascript-mask-api-key-stack-trace

Conversation

@bblair31

@bblair31 bblair31 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🧭 What and Why

Non-retryable 4xx errors (ApiError / DetailedApiError) kept the raw x-algolia-api-key header in error.stackTrace. Logging or serializing the error put the key into the logs.

Which, best I can tell, server-side is usually a write or admin key. RetryError and retry logging already mask it. It looks like v4 masked this path too (and the other language clients don't keep request headers on errors), so I think this is a v5 regression specific to JS.

Changes included:

  • Mask credentials in the stack trace passed to deserializeFailure (createTransporter.ts).
  • Add a test checking that the API key header is masked in every stack frame of a 4xx error (correlationId.test.ts).

πŸ§ͺ Test

  1. Prerequisite: yarn in clients/algoliasearch-client-javascript.
  2. In packages/client-common, run yarn test. All tests pass.
  3. Revert the one-line change and rerun. "masks the API key in every stack frame of 4xx errors" fails with the key visible in both frames.

@algolia-api-clients-automation-bot

algolia-api-clients-automation-bot Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

No code generated

If you believe code should've been generated, please, report the issue.

πŸ“Š Benchmark results

Benchmarks performed on the method using a mock server, the results might not reflect the real-world performance.

Language Req/s
javascript 2242

@bblair31 bblair31 self-assigned this Oct 22, 2026
@bblair31
bblair31 marked this pull request as ready for review October 22, 2026 19:37
@bblair31
bblair31 requested a review from a team as a code owner October 22, 2026 19:37
@Fluf22
Fluf22 merged commit 479b0cc into main Oct 23, 2026
18 checks passed
@Fluf22
Fluf22 deleted the fix/javascript-mask-api-key-stack-trace branch October 23, 2026 08:09
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-javascript that referenced this pull request Oct 23, 2026
algolia/api-clients-automation#7182

Co-authored-by: Brennan Blair <36816721+bblair31@users.noreply.github.com>
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.

2 participants