Skip to content

Conversation

@orbin123
Copy link
Contributor

@orbin123 orbin123 commented Dec 30, 2025

Pull Request

Related issue

Fixes #1185

What does this PR do?

This PR updates the SDK to be compatible with the Meilisearch v1.30 Network API (High Availability), which introduced breaking changes by removing the deprecated sharding configuration in favor of a Leader/Follower topology.

Changes:

  • Updated Docstrings: Refreshed client.add_or_update_networks and client.get_all_networks documentation to reflect the new remotes and leader payload structure, removing obsolete references to sharding.
  • Added Code Samples: Added missing get_network_1 and update_network_1 examples to .code-samples.meilisearch.yaml demonstrating the new API usage.
  • Updated Tests:
    • Refactored tests/client/test_client_network.py to remove legacy sharding: true tests which are now invalid.
    • Added test_configure_as_leader to verify configuring the client as a Leader with Follower remotes.
    • Ensured network tests properly enable the experimental feature using the enable_network_options fixture.

Summary by CodeRabbit

  • New Features

    • Added code examples showing how to retrieve networks and configure High Availability (leader/follower).
  • Documentation

    • Clarified network topology configuration, specifying required fields for remotes and leader.
  • Tests

    • Added a test for configuring an instance as leader with a follower and removed an outdated expectation for a "self" field in network payloads.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 30, 2025

📝 Walkthrough

Walkthrough

Adds two network code samples, clarifies the add_or_update_networks docstring to describe leader/follower topology and the remotes/leader parameters, and updates tests to use a remotes map with leader: None, removing the previous self field expectation.

Changes

Cohort / File(s) Change Summary
Examples & config
.code-samples.meilisearch.yaml
Added two samples: get_network_1 (calls client.get_all_networks()) and update_network_1 (calls client.add_or_update_networks(...) with a remotes map and leader: null).
Client docs
meilisearch/client.py
Edited add_or_update_networks docstring to describe network topology (Leader/Followers) and explain expected remotes map or leader key; no signature or behavior changes.
Tests
tests/client/test_client_network.py
Removed top-level self from request/response expectations and its assertion; added test_configure_as_leader to validate configuring as leader with one follower via remotes and leader: None.
Formatting
tests/settings/test_settings_embedders.py
Minor whitespace change in test_huggingface_embedder_format inline comment only (no behavior change).

Sequence Diagram(s)

(omitted — changes are examples, docstring edits, and tests without new multi-component control flow)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

maintenance

Suggested reviewers

  • Strift
  • sanders41
  • brunoocasali

Poem

🐰 I hopped through docs and tests today,
Remotes in rows, leader tucked away.
Examples added, assertions lean,
A tiny rabbit's QA routine.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: updating the Network API for Meilisearch v1.30 compatibility, which aligns with the core objective of this PR.
Linked Issues check ✅ Passed The PR successfully addresses all three coding requirements from issue #1185: adds network endpoint interaction support (via docstring updates), includes test cases (test_configure_as_leader), and updates code samples (get_network_1 and update_network_1 in .code-samples.meilisearch.yaml).
Out of Scope Changes check ✅ Passed All changes are directly aligned with the PR objectives; only one minor unrelated formatting change (extra space in test_settings_embedders.py comment) is present but does not affect core functionality.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd08d7c and 05036e5.

📒 Files selected for processing (1)
  • meilisearch/client.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • meilisearch/client.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
meilisearch/client.py (1)

900-922: Clarify parameter documentation for the Network HA configuration.

The updated docstring improves clarity, but the parameter documentation could be more precise:

  1. The description states "must contain either" but the type signature allows None as a valid value. Consider documenting when None is appropriate.
  2. The mutual exclusivity of 'remotes' vs. 'leader' isn't entirely clear. Based on the code sample in .code-samples.meilisearch.yaml (lines 10-17), both fields can be present simultaneously (e.g., {"remotes": {...}, "leader": None}).
  3. Consider clarifying the use cases:
    • Setting "remotes" with "leader": None configures this instance as a Leader with specified Followers
    • Setting "leader" with a URL configures this instance as a Follower pointing to the Leader
Suggested documentation improvement
     def add_or_update_networks(self, body: Union[MutableMapping[str, Any], None]) -> Dict[str, str]:
         """Configure the Network High Availability (Leader/Followers).

         Parameters
         ----------
         body:
-            The network configuration dictionary. must contain either:
-            - 'remotes': A dictionary of follower instances (Star Topology).
-            - 'leader': A string URL of the leader instance.
+            The network configuration dictionary:
+            - For Leader configuration: Set 'remotes' to a dictionary of follower instances and 'leader' to None.
+            - For Follower configuration: Set 'leader' to the Leader's URL string.
+            - Pass None to retrieve current configuration without changes.

         Returns
.code-samples.meilisearch.yaml (1)

9-17: Consider using a placeholder instead of "masterKey" in the code sample.

The code sample uses "masterKey" as the searchApiKey value. While this may work in local development, it could encourage insecure practices if users copy this directly to production environments.

Suggested improvement
 update_network_1: |-
   client.add_or_update_networks({
       "remotes": {
           "http://localhost:7700": {
-              "searchApiKey": "masterKey"
+              "searchApiKey": "your_search_api_key_here"
           }
       },
       "leader": None
   })
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 54b5e34 and 0fa99bf.

📒 Files selected for processing (3)
  • .code-samples.meilisearch.yaml
  • meilisearch/client.py
  • tests/client/test_client_network.py
🧰 Additional context used
🧬 Code graph analysis (1)
tests/client/test_client_network.py (2)
tests/conftest.py (1)
  • client (15-16)
meilisearch/client.py (1)
  • add_or_update_networks (900-922)
🪛 GitHub Actions: Tests
tests/client/test_client_network.py

[error] 1-1: Black formatting check failed. 1 file would be reformatted, 75 files would be left unchanged. Run 'pipenv run black meilisearch tests --check' to format the code.

Copy link
Contributor Author

@orbin123 orbin123 left a comment

Choose a reason for hiding this comment

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

style: fix black formatting

Copy link
Contributor Author

@orbin123 orbin123 left a comment

Choose a reason for hiding this comment

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

passing black millisearch tests

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0fa99bf and d411e24.

📒 Files selected for processing (1)
  • tests/client/test_client_network.py
🧰 Additional context used
🧬 Code graph analysis (1)
tests/client/test_client_network.py (3)
tests/conftest.py (1)
  • client (15-16)
meilisearch/client.py (1)
  • add_or_update_networks (900-922)
tests/test_utils.py (1)
  • reset_network_config (37-38)
🪛 GitHub Actions: Tests
tests/client/test_client_network.py

[error] 1-1: pipenv run black meilisearch tests --check failed. 1 file would be reformatted (tests/client/test_client_network.py). Run 'pipenv run black' to fix code style issues.

@orbin123 orbin123 closed this Dec 30, 2025
@orbin123 orbin123 deleted the feat/1185-update-network-api-compat branch December 30, 2025 09:55
@orbin123 orbin123 restored the feat/1185-update-network-api-compat branch December 30, 2025 09:58
@orbin123 orbin123 reopened this Dec 30, 2025
Copy link
Contributor Author

@orbin123 orbin123 left a comment

Choose a reason for hiding this comment

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

black formatting resolved

…n123/meilisearch-python into feat/1185-update-network-api-compat
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/client/test_client_network.py (1)

42-60: Good progress addressing previous feedback; use consistent parameter style.

The test successfully implements the previously requested improvements (cleanup, isinstance check, leader assertion). However, there's a style inconsistency at line 54.

Style inconsistency: Line 54 uses client.add_or_update_networks(body) (positional argument), while line 32 in test_add_or_update_networks uses client.add_or_update_networks(body=body) (keyword argument). For consistency within the test file, prefer the keyword argument style.

Optional enhancement: Consider verifying the remote's structure to make assertions more robust, as suggested in previous reviews.

🔎 Suggested improvements
-    response = client.add_or_update_networks(body)
+    response = client.add_or_update_networks(body=body)
 
     assert isinstance(response, dict)
     assert REMOTE_MS_1 in response["remotes"]
+    assert response["remotes"][REMOTE_MS_1]["url"] == "http://localhost:7701"
+    assert response["remotes"][REMOTE_MS_1]["searchApiKey"] == "remoteSearchKey"
     assert response.get("leader") is None
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d411e24 and fd08d7c.

📒 Files selected for processing (2)
  • tests/client/test_client_network.py
  • tests/settings/test_settings_embedders.py
✅ Files skipped from review due to trivial changes (1)
  • tests/settings/test_settings_embedders.py
🧰 Additional context used
🧬 Code graph analysis (1)
tests/client/test_client_network.py (3)
tests/conftest.py (1)
  • client (15-16)
meilisearch/client.py (1)
  • add_or_update_networks (900-922)
tests/test_utils.py (1)
  • reset_network_config (37-38)

Copy link
Contributor

@Strift Strift left a comment

Choose a reason for hiding this comment

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

hey @orbin123 thanks for this contribution!

Can you double-check all the documentation, please? I suggested some changes.

It looks like it's AI-generated because it doesn't match the feature documentation. It's better to be succinct than misleading.

orbin123 and others added 2 commits December 31, 2025 21:04
Co-authored-by: Laurent Cazanove <lau.cazanove@gmail.com>
Co-authored-by: Laurent Cazanove <lau.cazanove@gmail.com>
@orbin123
Copy link
Contributor Author

Sir, I have commited the necessary documentation changes. thankyou

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.

[v1.30] Update Network API compatibility

2 participants