Repository navigation
feat(javascript): Request-ID and Correlation-ID support - #6747
Merged
Merged
Conversation
Contributor
βοΈ Code generated!
π Benchmark resultsBenchmarks performed on the method using a mock server, the results might not reflect the real-world performance.
|
eric-zaharia
force-pushed
the
feat/js-request-id-correlation-id
branch
from
July 20, 2026 13:56
38831ac to
5fdebc2
Compare
xroche
approved these changes
Jul 24, 2026
Attach the Correlation-ID response header to ApiError, DetailedApiError and RetryError as an optional structured field, appended to the message. Read case-insensitively; the edge PoPs' unrelated X-Algolia-RequestID header is never used. Missing header leaves errors unchanged. Also registers the previously-orphaned withHttpInfo.test.ts in vitest.config.ts (it was never listed, so it never ran) and fixes its error assertions for vitest 4's deep comparison.
11-char [0-9A-Za-z] identifier, generated via crypto.getRandomValues with a Math.random fallback for runtimes without the crypto global. Not wired into the transporter yet.
New requestIdChannel transporter option ('headers' | 'queryParameters',
undefined = off; no client sets it yet). The ID is generated once per
execution after the cache/dedup key is built, reused across every
retry/host-fallback attempt, and fresh per call. A caller-supplied
Request-ID (header or x-algolia-request-id query parameter) is never
overwritten. Covers request, requestWithHttpInfo and requestStream.
New requestIdSupport generator flag scoped to search, recommend, composition and algoliasearch; the node and liteNode build templates set requestIdChannel: 'headers' for those clients. Browser, fetch and worker builds send no Request-ID: production currently rejects the x-algolia-request-id query parameter with a 400 on strict-validation endpoints (SRCH-9380 not fully converged), and the header would fail CORS preflights.
β¦uilds (API-516)
β¦plications (API-516)
β¦ansformation search calls (API-516)
β¦ the authMode CTS test (API-516)
β¦nnel Request-ID precedence (API-516) (#6758) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
eric-zaharia
force-pushed
the
feat/js-request-id-correlation-id
branch
from
August 3, 2026 07:16
cc048d2 to
f1c4f4f
Compare
algolia-api-clients-automation-bot Bot
added a commit
that referenced
this pull request
Aug 3, 2026
β¦rated) [skip ci] Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com> Co-authored-by: Xavier Roche <xavier.roche@algolia.com>
algolia-api-clients-automation-bot Bot
added a commit
to algolia/algoliasearch-client-javascript
that referenced
this pull request
Aug 3, 2026
algolia/api-clients-automation#6747 Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com> Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com> Co-authored-by: Xavier Roche <xavier.roche@algolia.com>
This was referenced Aug 10, 2026
This was referenced Aug 10, 2026
This was referenced Aug 10, 2026
This was referenced Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
π§ What and Why
π API-516 (epic API-515 Β· spec)
JavaScript reference implementation of the search clusters' tracing contract, reviewed by Engines before the 10 language ports.
Correlation-IDaserror.correlationIdand appended to the message:Invalid API key (Correlation-ID: β¦). Customers can quote it to support without inspecting raw HTTP. Header absent β errors byte-identical to today.Request-IDheader; browser/fetch/worker builds (incl. lite) send thex-algolia-request-idquery parameter, which never triggers a CORS preflight. A caller-supplied ID always wins, and minting happens after the cache/dedup boundary β cache keys and request deduplication are provably unchanged. Coversrequest,requestWithHttpInfoandrequestStream.Scoped via a
requestIdSupportgenerator flag to search, recommend, composition, algoliasearch (+lite); all other clients' generated code is untouched (their bundles grow ~0.25KB becauseclient-commoncarries the plumbing β abtesting/recommend budgets bumped accordingly). Non-breaking: trailing optional params on the error classes, new optionalrequestIdChanneltransporter option (undefined= off).π Behavioral notes
requestOptionsto their internal calls. The helper docstrings have always documented thatrequestOptionsare forwarded to thewaitForTask/getTaskpolls, and the batch writes insidechunkedBatch/replaceAllObjectsalready forwarded them β but the polls (andreplaceAllObjects' failure-pathdeleteIndex, plusindexExistsinaccountCopyIndex) were called bare. They now receive the caller'srequestOptions, which is also what lets one helper invocation share a single Request-ID. Side effect to be aware of: caller-supplied headers, query parameters and timeouts now apply to those internal requests too.error.message. Signatures and absent-header behavior are unchanged, but consumers matching exact message strings will see the suffix appear based on server-side header rollout, not client version βerror.correlationIdis the stable way to read it.π§ͺ Test
client-commonand allalgoliasearchbuilds: cache key unchanged, dedup shares one ID, same ID across retries, fresh per call, caller precedence, per-build channel, CID on 4xx/retry-exhaustion/timeout paths, edgeX-Algolia-RequestIDnever read.request-idthe client sent (suffix echo), and real API errors surface their CID.withHttpInfo.test.tswas never registered invitest.config.tsβ registered and its assertions fixed.