Skip to content

Preserve empty lists and zero in JSON request bodies - #1294

Draft
Kayvan-Zahiri wants to merge 1 commit into
meilisearch:mainfrom
Kayvan-Zahiri:codex/preserve-empty-json-request-values
Draft

Kayvan-Zahiri wants to merge 1 commit into
meilisearch:mainfrom
Kayvan-Zahiri:codex/preserve-empty-json-request-values

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

Closes #1293.

Problem

The request serializer treats an empty list as a missing body and sends null. This changes settings semantics: index.update_searchable_attributes([]) resets the local server to ["*"] rather than configuring []. Displayed attributes and ranking rules have the same issue. Numeric zero also becomes null.

Change

JSON-serialize every non-byte body except the existing empty-string sentinel. This preserves empty lists and zero while retaining None as null, booleans, empty dictionaries, raw bytes, empty strings, and the custom encoder argument.

Add public SDK integration tests for searchable attributes, displayed attributes and ranking rules, verifying an empty list stays empty and None still resets the setting. Add wire-value controls for falsey request bodies.

Validation

Using the locked uv sync --frozen environment (Python 3.12) and an isolated official local Meilisearch 1.55.0 community server:

  • Before the source fix: 5 regression cases fail, 8 controls pass.
  • Focused HTTP/request integration suite after: 13 passed.
  • Focused suite plus tests/index: 174 passed, 2 failed because inlineRule requires Enterprise Edition. Both failures reproduce on unchanged upstream source; they are unrelated to serialization.
  • Full repository Ruff lint and format checks pass; MyPy passes across all 17 source files; git diff --check passes.

The full SDK/server matrix was not run. No hosted data or cloud account was used.

AI assistance: Codex assisted with source inspection, implementation, tests, and this description. The reproduction and regression checks were executed locally.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

This branch has not been deployed

No deployments
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.

Empty list settings are serialized as null and reset instead of staying empty

1 participant