Skip to content

fix(specs): add searchResponsePartial fallback to searchResult oneOf - #6350

Merged
eric-zaharia merged 4 commits into
mainfrom
fix/searchResult-responseFields-fallback
May 26, 2026
Merged

eric-zaharia merged 4 commits into
mainfrom
fix/searchResult-responseFields-fallback

Conversation

@Fluf22

@Fluf22 Fluf22 commented May 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a searchResponsePartial schema as a third oneOf variant in searchResult
  • Fixes deserialization failures when responseFields strips required fields like hits

Context

#6199 auto-infers discriminator fields from unique required properties. For searchResult, this gives searchResponse a hits discriminator and searchForFacetValuesResponse keeps its explicit facetHits discriminator.

When a user sets responseFields to a subset excluding hits (e.g. ["nbHits"]), the API returns a valid search response without hits. Both discriminator checks fail → deserialization throws InvalidDataException. Affects all languages with discriminator-guarded oneOf deserialization.

Fix

searchResponsePartial has the same properties as searchResponse (baseSearchResponse + SearchPagination + hits/query/params/extensions) but no required fields. Since inferDiscriminatorFields can't compute unique required fields for it, no discriminator is inferred. sortOneOfs places it last (variants with discriminators sort first).

Deserialization order becomes:

  1. searchForFacetValuesResponse — discriminator facetHits → tried first
  2. searchResponse — discriminator hits → tried second
  3. searchResponsePartial — no discriminator → unconditional catch-all

No generator changes needed.

References

When responseFields strips required fields like hits, neither the
searchResponse (discriminator: hits) nor searchForFacetValuesResponse
(discriminator: facetHits) variant matches, causing deserialization to
throw across all languages.

Add a third oneOf variant (searchResponsePartial) with all search
response properties but no required fields. Since it has no required
fields, the generator cannot infer discriminators for it, so sortOneOfs
places it last as an unconditional catch-all.

Fixes API-464
@Fluf22
Fluf22 requested a review from a team as a code owner May 11, 2026 17:52
@algolia-bot

algolia-bot commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

✔️ Code generated!

Name Link
🪓 Triggered by 460231cb0bf0007f1120013dc1af56dc38cb162b
🍃 Generated commit 07391da4cacd2b3f7856aa731edb60bc0e982a5b
🌲 Generated branch generated/fix/searchResult-responseFields-fallback
📊 Benchmark results

Benchmarks performed on the method using a mock server, the results might not reflect the real-world performance.

Language Req/s
go 2574
javascript 2475
php 1718
csharp 1368
python 1361
java 1153
ruby 963
swift 779
scala 23

@codacy-production

codacy-production Bot commented May 11, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

TIP This summary will be updated as you push new changes.

@eric-zaharia
eric-zaharia merged commit 35bf16c into main May 26, 2026
36 checks passed
@eric-zaharia
eric-zaharia deleted the fix/searchResult-responseFields-fallback branch May 26, 2026 08:46
algolia-bot added a commit that referenced this pull request May 26, 2026
…6350) (generated) [skip ci]

Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
algolia-bot added a commit to algolia/algoliasearch-client-csharp that referenced this pull request May 26, 2026
…(generated)

algolia/api-clients-automation#6350

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
algolia-bot added a commit to algolia/algoliasearch-client-dart that referenced this pull request May 26, 2026
…(generated)

algolia/api-clients-automation#6350

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
algolia-bot added a commit to algolia/algoliasearch-client-go that referenced this pull request May 26, 2026
…(generated)

algolia/api-clients-automation#6350

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
algolia-bot added a commit to algolia/algoliasearch-client-java that referenced this pull request May 26, 2026
…(generated)

algolia/api-clients-automation#6350

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
algolia-bot added a commit to algolia/algoliasearch-client-javascript that referenced this pull request May 26, 2026
…(generated)

algolia/api-clients-automation#6350

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
algolia-bot added a commit to algolia/algoliasearch-client-kotlin that referenced this pull request May 26, 2026
…(generated)

algolia/api-clients-automation#6350

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
algolia-bot added a commit to algolia/algoliasearch-client-php that referenced this pull request May 26, 2026
…(generated)

algolia/api-clients-automation#6350

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
algolia-bot added a commit to algolia/algoliasearch-client-python that referenced this pull request May 26, 2026
…(generated)

algolia/api-clients-automation#6350

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
algolia-bot added a commit to algolia/algoliasearch-client-ruby that referenced this pull request May 26, 2026
…(generated)

algolia/api-clients-automation#6350

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
algolia-bot added a commit to algolia/algoliasearch-client-scala that referenced this pull request May 26, 2026
…(generated)

algolia/api-clients-automation#6350

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
algolia-bot added a commit to algolia/algoliasearch-client-swift that referenced this pull request May 26, 2026
…(generated)

algolia/api-clients-automation#6350

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
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.

3 participants