Skip to content

Fix Jackson serialization of granular filterable attributes - #985

Merged
Strift merged 2 commits into
meilisearch:mainfrom
Moustafa-Ameen:agent/fix-filterable-attributes-jackson
Jul 28, 2026
Merged

Fix Jackson serialization of granular filterable attributes#985
Strift merged 2 commits into
meilisearch:mainfrom
Moustafa-Ameen:agent/fix-filterable-attributes-jackson

Conversation

@Moustafa-Ameen

@Moustafa-Ameen Moustafa-Ameen commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Related issue

Fixes #973

What does this PR do?

Fixes Jackson serialization when callers use granular filterableAttributesConfig values. Jackson previously invoked the legacy getFilterableAttributes() accessor, which throws when a configuration contains granular feature settings.

  • Maps the granular getter and setter to the API's filterableAttributes JSON property.
  • Excludes the legacy String[] getter and setter from Jackson serialization while retaining them as public SDK methods.
  • Adds a regression test covering an advanced configuration with features.filter and facetSearch settings.

Validation

  • ./gradlew.bat compileTestJava --no-daemon
  • Direct Jackson encode/decode checks for advanced granular and legacy string configurations.
  • git diff --check

The full test task is blocked locally because the repository's Mockito 4 / JaCoCo 0.8.8 test setup is incompatible with the installed Java 24 runtime; the failure occurs during test initialization before assertions run.

AI usage

I used Codex to help inspect the affected serialization path and draft the implementation and regression test. I reviewed the code and validated the behavior locally.

PR checklist

  • This PR fixes an existing issue.
  • I have read the contributing guidelines.
  • The title accurately describes the change.

Summary by CodeRabbit

  • Bug Fixes
    • Improved JSON serialization/deserialization for advanced filterable-attribute configurations.
    • Prevented legacy filterable-attribute fields from appearing alongside the newer configuration in JSON output.
    • Ensured facet-search and filter feature settings round-trip accurately through JSON.
  • Tests
    • Added a round-trip test that validates the exact JSON and verifies decoded advanced filterable-attribute feature and filter values.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 75806ee8-4acd-41b4-aff6-500e0ae286e4

📥 Commits

Reviewing files that changed from the base of the PR and between 295e0fb and 2eb7ead.

📒 Files selected for processing (1)
  • src/test/java/com/meilisearch/sdk/json/JacksonJsonHandlerTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/com/meilisearch/sdk/json/JacksonJsonHandlerTest.java

📝 Walkthrough

Walkthrough

Settings now maps granular filterable-attributes configuration to filterableAttributes, ignores the legacy accessor during serialization, and verifies the behavior through an advanced configuration round-trip test.

Changes

Granular filterable attributes

Layer / File(s) Summary
Settings JSON mapping and round-trip validation
src/main/java/com/meilisearch/sdk/model/Settings.java, src/test/java/com/meilisearch/sdk/json/JacksonJsonHandlerTest.java
Jackson annotations expose granular configuration as filterableAttributes, exclude the legacy accessor, and test exact JSON encoding plus decoded feature and filter values.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

I’m a rabbit with settings to share,
Granular filters now travel with care.
Legacy paths hide from the JSON stream,
Round-trip tests verify the scheme.
Hop, hop—Jackson gets the dream!

🚥 Pre-merge checks | ✅ 5
✅ 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 describes the main change to Jackson serialization for granular filterable attributes.
Linked Issues check ✅ Passed The PR addresses #973 by serializing granular filterable attributes via filterableAttributes and preserving the legacy String[] API.
Out of Scope Changes check ✅ Passed The changes stay focused on Settings Jackson annotations and a regression test, with no unrelated edits.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Tools execution failed with the following error:

Failed to run tools: 14 UNAVAILABLE: read ECONNRESET


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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/com/meilisearch/sdk/model/Settings.java`:
- Around line 64-65: Remove the `@JsonIgnore` from the String[] overload
`Settings.setFilterableAttributes(String[])` so Jackson can deserialize legacy
`filterableAttributes` arrays while retaining granular-object configuration
handling. Add a regression test covering a payload such as
`{"filterableAttributes":["title"]}` and verify the resulting settings preserve
the decoded legacy values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8f2250d6-3821-4d59-9241-6ed566bd3416

📥 Commits

Reviewing files that changed from the base of the PR and between aad10f0 and 295e0fb.

📒 Files selected for processing (2)
  • src/main/java/com/meilisearch/sdk/model/Settings.java
  • src/test/java/com/meilisearch/sdk/json/JacksonJsonHandlerTest.java

Comment thread src/main/java/com/meilisearch/sdk/model/Settings.java
Co-authored-by: Cursor <cursoragent@cursor.com>
@Strift Strift added the bug Something isn't working label Jul 28, 2026

@Strift Strift 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.

Hello @Moustafa-Ameen and thanks for your contribution 🙌 LGTM!

@Strift
Strift added this pull request to the merge queue Jul 28, 2026
Merged via the queue into meilisearch:main with commit c1b30d2 Jul 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Index.updateSettings with filterableAttributesConfig fails with Jackson

2 participants