Skip to content

fix(specs): allow null records in getObjects response - #6582

Merged
Fluf22 merged 4 commits into
mainfrom
fix/get-objects-nullable
Jun 22, 2026
Merged

Fluf22 merged 4 commits into
mainfrom
fix/get-objects-nullable

Conversation

@Fluf22

@Fluf22 Fluf22 commented Jun 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The Algolia engine returns null entries in the getObjects results array when a requested objectID doesn't exist in the index, but the spec typed results items as non-null. This caused deserialization crashes in strongly-typed clients.

Fixes algolia/algoliasearch-client-kotlin#427
Fixes algolia/algoliasearch-client-swift#892
Fixes algolia/algoliasearch-client-csharp#873

This is a spec issue: the contract didn't reflect the engine's actual behavior (verified against the AlgoliaSaaS engine, which explicitly pushes null for missing objectIDs).

Changes

  • Spec: mark getObjects results items as nullable: true (kept inline rather than the oneOf: [..., type: 'null'] convention, because that convention is incompatible with x-is-generic β€” it materializes a concrete GetObjectsResponseResultsInner model and drops the generic T).
  • Generic templates (Swift, C#, JavaScript/TS): propagate nullability to the generic element type when items.isNullable.
  • Dart generator: rewrite nullable array item datatypes (List<Object> β†’ List<Object?>).
  • Go generator: collapse the redundant []*map[string]any back to []map[string]any, since a map is already a nilable reference type (no breaking change vs current type).

Resulting element types

Client results element type
Kotlin List<JsonObject?>
Python List[Optional[object]]
Go []map[string]any (nil = null)
Swift [T?]
C# List<T?>
TypeScript (T | null)[]
Dart List<Object?>

Java, Scala, PHP, and Ruby are already null-tolerant at the type level, so no change is needed.

@algolia-api-clients-automation-bot

algolia-api-clients-automation-bot Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

βœ”οΈ Code generated!

Name Link
πŸͺ“ Triggered by 39afde14f7db13a247108d917d9abdfce76e982a
πŸƒ Generated commit 41e7c93ddacb30a0a6dedc463983a421c1b4d829
🌲 Generated branch generated/fix/get-objects-nullable
πŸ“Š Benchmark results

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

Language Req/s
javascript 2306
php 1926
go 1848
csharp 1567
python 1410
java 1068
ruby 842
swift 745
scala 23

The engine returns `null` for requested objectIDs that don't exist in the
index, but the `results` array was typed as non-null, which crashed
deserialization in strongly-typed clients (e.g. Kotlin, Swift).

Mark the `results` items as nullable and propagate nullability through the
generic type templates (Swift, C#, JavaScript/TS) and the Dart generator.
For Go, collapse the redundant `[]*map[string]any` back to `[]map[string]any`
since a map is already a nilable reference type.
@Fluf22
Fluf22 force-pushed the fix/get-objects-nullable branch from 2d67586 to 6aca28e Compare June 18, 2026 12:32
@Fluf22
Fluf22 marked this pull request as ready for review June 18, 2026 13:01
@Fluf22
Fluf22 requested a review from a team as a code owner June 18, 2026 13:01
Fluf22 added 3 commits June 18, 2026 15:34
Add a client CTS case asserting that a `getObjects` response containing a
`null` entry (returned for objectIDs that don't exist in the index) alongside
a real record deserializes correctly. Locks the behavior fixed by marking the
results items nullable.
The getObjects CTS test exposed two Ruby issues with null records:
- client test rendering inlined the JSON `null` token as Ruby code, which is
  invalid (must be `nil`); add a `rubyNil` lambda to convert it.
- `_to_hash` called `.compact`, stripping null entries from arrays in
  `to_hash`/`to_json`/`to_body`; drop it so null array elements are preserved.
@Fluf22
Fluf22 merged commit a632f9f into main Jun 22, 2026
36 checks passed
@Fluf22
Fluf22 deleted the fix/get-objects-nullable branch June 22, 2026 09:09
algolia-api-clients-automation-bot Bot added a commit that referenced this pull request Jun 22, 2026
…ted) [skip ci]

Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-csharp that referenced this pull request Jun 22, 2026
algolia/api-clients-automation#6582

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-dart that referenced this pull request Jun 22, 2026
algolia/api-clients-automation#6582

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-go that referenced this pull request Jun 22, 2026
algolia/api-clients-automation#6582

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-java that referenced this pull request Jun 22, 2026
algolia/api-clients-automation#6582

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-javascript that referenced this pull request Jun 22, 2026
algolia/api-clients-automation#6582

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-kotlin that referenced this pull request Jun 22, 2026
algolia/api-clients-automation#6582

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-php that referenced this pull request Jun 22, 2026
algolia/api-clients-automation#6582

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-python that referenced this pull request Jun 22, 2026
algolia/api-clients-automation#6582

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-ruby that referenced this pull request Jun 22, 2026
algolia/api-clients-automation#6582

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-scala that referenced this pull request Jun 22, 2026
algolia/api-clients-automation#6582

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-swift that referenced this pull request Jun 22, 2026
algolia/api-clients-automation#6582

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Thomas Raffray <Fluf22@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

2 participants