Skip to content

Conversation

@awais786
Copy link
Contributor

@awais786 awais786 commented Jan 1, 2026

#1186

Adds an optional skip_creation flag across document ingestion/update APIs to ignore creation of non-existent documents when true, and threads it via skipCreation=true query param.

… don't exist in the index are silently ignored rather than created.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 1, 2026

Warning

Rate limit exceeded

@awais786 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 3 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between f1778a9 and 3c22c85.

📒 Files selected for processing (3)
  • .code-samples.meilisearch.yaml
  • meilisearch/index.py
  • tests/index/test_index_document_meilisearch.py
📝 Walkthrough

Walkthrough

Added an optional skip_creation parameter to Index document add/update methods. When True, requests include skipCreation=true to silently ignore non-existent documents; when False or None, behavior is unchanged. The flag is propagated into URL construction and per-batch request paths; tests for skip_creation were added.

Changes

Cohort / File(s) Summary
Document addition & update methods
meilisearch/index.py
Added skip_creation: Optional[bool] = None to public methods that add/update documents (e.g., add_documents, add_documents_in_batches, add_documents_json, add_documents_csv, add_documents_ndjson, add_documents_raw, update_documents, update_documents_in_batches, update_documents_json, update_documents_csv, update_documents_ndjson, update_documents_raw). Signatures, docstrings, and internal call sites updated to thread the parameter.
URL construction & request plumbing
meilisearch/index.py
_build_url signature updated to accept skip_creation and append skipCreation=true when set. All relevant call sites (including per-batch handlers) now forward skip_creation into URL building and request execution.
Tests
tests/index/test_index_document_meilisearch.py
New tests added covering skip_creation true/false across add/update variants (single, batches, JSON, CSV, NDJSON) verifying creation suppression and update behavior.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Index
  participant URLBuilder as _build_url
  participant HTTP as "MeiliSearch API"

  Client->>Index: add/update documents(..., skip_creation=bool)
  Index->>URLBuilder: _build_url(primary_key, csv_delimiter, skip_creation)
  URLBuilder-->>Index: url (append ?skipCreation=true when True)
  Index->>HTTP: POST url + payload
  HTTP-->>Index: TaskInfo
  Index-->>Client: TaskInfo

  note right of Index: For batching, Index iterates batches and repeats URL build + POST per batch
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through code with a tiny mission,
A flag to hush new records—quiet precision,
Batches carry it forward, URLs wear the sign,
Existing docs update, stray ones decline,
A rabbit's nibble: tidy, small, and fine.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title mentions adding an optional skipCreation parameter and its behavior when set to true, which directly corresponds to the main changes in the PR.
Docstring Coverage ✅ Passed Docstring coverage is 96.15% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
meilisearch/index.py (1)

1-1: CRITICAL: Fix Black formatting before merge.

The pipeline shows a Black formatting failure. Run black meilisearch/index.py locally to fix formatting issues.

🧹 Nitpick comments (1)
meilisearch/index.py (1)

870-877: Consider making parameters keyword-only for consistency.

In update_documents_in_batches, the serializer and skip_creation parameters are not keyword-only, whereas in add_documents_in_batches (line 494-496) they are keyword-only (after the * separator).

For API consistency, consider adding the * separator:

 def update_documents_in_batches(
     self,
     documents: Sequence[Mapping[str, Any]],
     batch_size: int = 1000,
     primary_key: Optional[str] = None,
+    *,
     serializer: Optional[Type[JSONEncoder]] = None,
     skip_creation: Optional[bool] = None,
 ) -> List[TaskInfo]:

This matches the signature pattern used in add_documents_in_batches and other methods.

📜 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 7af27f2.

📒 Files selected for processing (1)
  • meilisearch/index.py
🧰 Additional context used
🧬 Code graph analysis (1)
meilisearch/index.py (2)
meilisearch/_httprequests.py (1)
  • put (120-140)
meilisearch/models/task.py (1)
  • TaskInfo (78-107)
🪛 GitHub Actions: Tests
meilisearch/index.py

[error] 1-1: Black formatting check failed. 1 file would be reformatted; run 'black' to format the code.

🔇 Additional comments (3)
meilisearch/index.py (3)

531-531: LGTM: Parameter propagation in batch methods.

The skip_creation parameter is correctly propagated through the batch processing methods to their underlying single-operation methods. This ensures consistent behavior across batch and non-batch operations.

Also applies to: 911-911


2389-2390: LGTM: Defensive check for boolean True.

The explicit if skip_creation is True: check is good defensive programming. It ensures only the boolean value True adds the query parameter, preventing truthy non-boolean values from inadvertently triggering the behavior. The string value "true" is correct for URL query parameters.


2378-2393: The implementation is correct. Verification confirms:

  1. Meilisearch API supports the skipCreation parameter on document endpoints (introduced in v1.31.0)
  2. The string value "true" is the correct format for URL query parameters
  3. The conditional if skip_creation is True: correctly ensures the parameter is only sent when explicitly set to True, preserving existing behavior (creation) when False or None

… don't exist in the index are silently ignored rather than created.
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

♻️ Duplicate comments (1)
meilisearch/index.py (1)

470-472: Docstring inaccuracy previously flagged.

The docstring still states "Default is False" when the actual default is None. This issue was already identified in a previous review for all 12 methods.

🧹 Nitpick comments (1)
meilisearch/index.py (1)

892-898: Consider making serializer and skip_creation keyword-only for consistency.

The signature of update_documents_in_batches differs from add_documents_in_batches (line 489-496). In add_documents_in_batches, both serializer and skip_creation are keyword-only parameters (separated by *), but in update_documents_in_batches they are positional. While this maintains consistency with the pre-existing pattern in each method, it creates an inconsistency between the two related batch methods.

Consider aligning both methods by making these parameters keyword-only:

def update_documents_in_batches(
    self,
    documents: Sequence[Mapping[str, Any]],
    batch_size: int = 1000,
    primary_key: Optional[str] = None,
    *,
    serializer: Optional[Type[JSONEncoder]] = None,
    skip_creation: Optional[bool] = None,
) -> List[TaskInfo]:
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7af27f2 and 9178380.

📒 Files selected for processing (1)
  • meilisearch/index.py
🧰 Additional context used
🧬 Code graph analysis (1)
meilisearch/index.py (2)
meilisearch/_httprequests.py (1)
  • put (120-140)
meilisearch/models/task.py (1)
  • TaskInfo (78-107)
🔇 Additional comments (1)
meilisearch/index.py (1)

2402-2417: The skipCreation parameter is supported by the Meilisearch API (added in v1.31.0) for document add/update endpoints. The implementation correctly constructs the URL with skipCreation=true when skip_creation is True, and the string value format is correct for URL query parameters.

… don't exist in the index are silently ignored rather than created.
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: 5

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9178380 and f0333d4.

📒 Files selected for processing (1)
  • tests/index/test_index_document_meilisearch.py
🧰 Additional context used
🧬 Code graph analysis (1)
tests/index/test_index_document_meilisearch.py (1)
meilisearch/index.py (7)
  • add_documents (451-487)
  • update_documents (696-732)
  • add_documents_json (538-578)
  • update_documents_json (767-807)
  • add_documents_csv (580-614)
  • update_documents_csv (809-843)
  • add_documents_ndjson (616-647)
🪛 GitHub Actions: Tests
tests/index/test_index_document_meilisearch.py

[error] 759-759: Test failure in test_update_documents_json_with_skip_creation: MeilisearchApiError due to malformed payload when adding documents with skip_creation.


[error] 788-788: Test failure in test_add_documents_csv_with_skip_creation: Expected 1 document after skip_creation, but got 0.


[error] 806-806: Test failure in test_update_documents_csv_with_skip_creation: Expected 1 document after skip_creation, but got 0.

🪛 Ruff (0.14.10)
tests/index/test_index_document_meilisearch.py

584-584: Do not assert blind exception: Exception

(B017)


650-650: Do not assert blind exception: Exception

(B017)

🔇 Additional comments (7)
tests/index/test_index_document_meilisearch.py (7)

592-606: LGTM!

This test correctly verifies that skip_creation=False preserves default behavior, allowing document creation.


608-629: LGTM!

This test correctly verifies the important distinction that skip_creation=True blocks creation of new documents while still allowing updates to existing ones.


658-679: LGTM!

This test correctly verifies that update_documents with skip_creation=True can still update existing documents.


681-702: LGTM!

This test correctly verifies that skip_creation works with batch operations, preventing creation of new documents while respecting existing ones.


704-725: LGTM!

This test correctly verifies that skip_creation works with update_documents_in_batches.


727-748: LGTM!

This test correctly verifies that skip_creation works with JSON document format.


809-824: LGTM!

This test correctly verifies that skip_creation works with NDJSON format. Unlike CSV, NDJSON has one document per line with no headers, so taking the first line is correct.

… don't exist in the index are silently ignored rather than created.
… don't exist in the index are silently ignored rather than created.
… don't exist in the index are silently ignored rather than created.
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: 2

♻️ Duplicate comments (2)
tests/index/test_index_document_meilisearch.py (2)

584-585: Use a specific exception type instead of bare Exception.

This issue was already identified in a previous review. Catching bare Exception is too broad and may hide unexpected errors. Use a specific exception type like MeilisearchApiError based on the imports and patterns used elsewhere in this file.


650-651: Use a specific exception type instead of bare Exception.

This issue was already identified in a previous review. Replace the bare Exception with a specific exception type like MeilisearchApiError.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0333d4 and f1778a9.

📒 Files selected for processing (1)
  • tests/index/test_index_document_meilisearch.py
🧰 Additional context used
🧬 Code graph analysis (1)
tests/index/test_index_document_meilisearch.py (1)
meilisearch/index.py (9)
  • add_documents (451-487)
  • wait_for_task (233-260)
  • update_documents (696-732)
  • add_documents_in_batches (489-536)
  • add_documents_json (538-578)
  • update_documents_json (767-807)
  • add_documents_csv (580-614)
  • update_documents_csv (809-843)
  • add_documents_ndjson (616-647)
🪛 GitHub Actions: Tests
tests/index/test_index_document_meilisearch.py

[error] 729-729: pylint: Import outside toplevel (json) (import-outside-toplevel)


[error] 752-752: pylint: Import outside toplevel (json) (import-outside-toplevel)

🪛 Ruff (0.14.10)
tests/index/test_index_document_meilisearch.py

584-584: Do not assert blind exception: Exception

(B017)


650-650: Do not assert blind exception: Exception

(B017)

… don't exist in the index are silently ignored rather than created.
… don't exist in the index are silently ignored rather than created.
@awais786
Copy link
Contributor Author

awais786 commented Jan 6, 2026

@Strift You can review this.

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