Skip to content

Fix Jackson serialization of granular filterable attributes#985

Open
Moustafa-Ameen wants to merge 1 commit into
meilisearch:mainfrom
Moustafa-Ameen:agent/fix-filterable-attributes-jackson
Open

Fix Jackson serialization of granular filterable attributes#985
Moustafa-Ameen wants to merge 1 commit 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

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 and deserialization for advanced filterable-attribute settings.
    • Prevented legacy filterable-attribute data from being duplicated in JSON output.
    • Preserved filter and facet-search configuration values during round trips.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 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

Suggested reviewers: strift

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 matches the main change: fixing Jackson serialization for granular filterable attributes.
Linked Issues check ✅ Passed The PR maps granular filterable attributes to the correct JSON property, ignores the legacy accessor, and adds a regression test as required by #973.
Out of Scope Changes check ✅ Passed The code changes stay focused on Jackson serialization behavior and the related test coverage.
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

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 on lines +64 to 65
@JsonIgnore
public Settings setFilterableAttributes(String[] filterableAttributes) {

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -A8 -B4 \
  '`@JsonIgnore`|setFilterableAttributes\(String\[\]|setFilterableAttributesConfig' \
  src/main/java/com/meilisearch/sdk/model/Settings.java

rg -n \
  'filterableAttributes.*\["|setFilterableAttributes\(new String' \
  src/test/java

Repository: meilisearch/meilisearch-java

Length of output: 2156


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Files:\n'
git ls-files 'src/main/java/com/meilisearch/sdk/model/Settings.java' 'src/main/java/com/meilisearch/sdk/model/Filterable*.java'

printf '\nSettings.java lines 1-110:\n'
cat -n src/main/java/com/meilisearch/sdk/model/Settings.java | sed -n '1,110p'

printf '\nFilterable attribute files:\n'
git ls-files 'src/main/java/com/meilisearch/sdk/model/Filterable*.java' | sort

for f in $(git ls-files 'src/main/java/com/meilisearch/sdk/model/Filterable*.java' | sort); do
  echo "--- $f"
  cat -n "$f" | sed -n '1,220p'
done

printf '\nDeserializer/adapter usages:\n'
rg -n "Settings|FilterableAttributesLegacyAdapter|FilterableAttributesConfig|filterableAttributes" src/main/java src/test/java | head -n 200

Repository: meilisearch/meilisearch-java

Length of output: 36584


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Files:\n'
git ls-files 'src/main/java/com/meilisearch/sdk/model/Settings.java' 'src/main/jsonschema' 'src/test/resources' | sed -n '1,200p'

printf '\nSettings.java lines 1-110:\n'
cat -n src/main/java/com/meilisearch/sdk/model/Settings.java | sed -n '1,110p'

printf '\nFilterable attribute files:\n'
git ls-files 'src/main/java/com/meilisearch/sdk/model/Filterable*.java' | sort

for f in $(git ls-files 'src/main/java/com/meilisearch/sdk/model/Filterable*.java' | sort); do
  echo "--- $f"
  cat -n "$f" | sed -n '1,220p'
done

printf '\nDeserializer/adapter usages:\n'
rg -n "Settings|FilterableAttributesLegacyAdapter|FilterableAttributesConfig|filterableAttributes" src/main/java src/test/java | head -n 200

Repository: meilisearch/meilisearch-java

Length of output: 36746


Preserve legacy filterableAttributes deserialization.

@JsonIgnore hides both the legacy string setter and getter, so Jackson no longer decodes legacy payloads like {"filterableAttributes":["title"]} through setFilterableAttributes(String[]). Keep deserialization working for the string legacy form in addition to granular-object config entries, and add a regression test for that legacy shape.

🤖 Prompt for 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.

In `@src/main/java/com/meilisearch/sdk/model/Settings.java` around lines 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.

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.

Index.updateSettings with filterableAttributesConfig fails with Jackson

1 participant