Skip to content

fix(javascript): add warning in replaceAllObjects for empty objects - #6608

Merged
eric-zaharia merged 12 commits into
mainfrom
port/replaceallobjects-empty-warning-20260626/javascript
Jul 20, 2026
Merged

eric-zaharia merged 12 commits into
mainfrom
port/replaceallobjects-empty-warning-20260626/javascript

Conversation

@eric-zaharia

@eric-zaharia eric-zaharia commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

🧭 What and Why

🎟 JIRA Ticket: API-500

Mirrors #6607 for JavaScript: replaceAllObjects and replaceAllObjectsWithTransformation now log a warning when called with an empty objects list, since the helper would otherwise silently empty the index. Behavior is unchanged — the call still proceeds.

Changes included:

  • Empty-list warning in replaceAllObjects (helpers.mustache) and replaceAllObjectsWithTransformation (definition.mustache), plus a Warning: JSDoc note on both so it shows on IDE hover.
  • The warning goes to the client's Logger if it implements the new optional warn method, and falls back to console.warn otherwise (new logWarning utility in client-common). Existing custom loggers keep compiling; the default null logger doesn't implement warn, so out-of-the-box users still see the warning, while anyone with a real logger can route or silence it.
  • createConsoleLogger implements warn (gated at the Info threshold), with tests.
  • Raised the client-search bundlewatch budget 10KB → 11KB (feat(javascript): add WithHTTPInfo methods #6682 left it at 9.97KB; the warning code tipped it over).
  • Fixed the flaky with logger tests in the four algoliasearch build variants (browser/node/fetch/worker): each fired an un-awaited real setSettings request whose retries raced vitest pool teardown and intermittently failed the client javascript CI job with all tests green (it killed this PR's CI twice in a row). The tests now await a mock requester that returns a retryable 500 and assert the transporter's actual Retryable failure log — the old inner assertions never executed.

Usage

await client.replaceAllObjects({ indexName: "products", objects: [] });
// console.warn: replaceAllObjects was called with an empty list of objects,
// which will delete all records currently in the "products" index.

@algolia-api-clients-automation-bot

algolia-api-clients-automation-bot Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

✔️ Code generated!

Name Link
🪓 Triggered by 472701453e6b03bbc85afc6318489679fb01c5d1
🍃 Generated commit 2ae9b1ea20c85d1399570cce10194e6e3357c76b
🌲 Generated branch generated/port/replaceallobjects-empty-warning-20260626/javascript
📊 Benchmark results

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

Language Req/s
javascript 2283

@eric-zaharia
eric-zaharia marked this pull request as ready for review June 26, 2026 09:14
@eric-zaharia
eric-zaharia requested a review from a team as a code owner June 26, 2026 09:14
@eric-zaharia eric-zaharia self-assigned this Jun 26, 2026
@eric-zaharia
eric-zaharia requested a review from Fluf22 July 6, 2026 11:07
eric-zaharia and others added 8 commits July 15, 2026 12:43
The `with logger` test in each algoliasearch build variant fired an
un-awaited setSettings call against unresolvable hosts; the leaked
retries raced vitest pool teardown and intermittently failed the
client javascript CI job even with all tests passing. Replace the real
request with a mock requester returning a retryable 500, await the
rejection, and assert the transporter's actual `Retryable failure`
logger output (the old inner assertions never executed).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

@MarioAlexandruDan MarioAlexandruDan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@eric-zaharia
eric-zaharia merged commit 816ba11 into main Jul 20, 2026
13 checks passed
@eric-zaharia
eric-zaharia deleted the port/replaceallobjects-empty-warning-20260626/javascript branch July 20, 2026 11:43
algolia-api-clients-automation-bot Bot added a commit that referenced this pull request Jul 20, 2026
…6608) (generated) [skip ci]

Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-javascript that referenced this pull request Jul 20, 2026
…generated)

algolia/api-clients-automation#6608

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: Claude <noreply@anthropic.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-swift that referenced this pull request Jul 20, 2026
…generated)

algolia/api-clients-automation#6608

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: Claude <noreply@anthropic.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.

3 participants