Skip to content

Conversation

@shortcuts
Copy link
Member

🧭 What and Why

🎟 JIRA Ticket: https://algolia.atlassian.net/browse/CR-8953 https://algolia.atlassian.net/browse/DI-4020

Changes included:

closes algolia/algoliasearch-client-python#569

When calling to_dict on a search response, pydantic yells about recursion issue and incorrect typings of our HighlightResult and SnippetResults models.

image

I tried many ways to solve this, and sadly the only other solution that would work (except the one proposed in this PR) is to implement a custom serializer for every models, which would be a much harder work to put in place.

In the meantime, I propose using a custom serializer (with the field_serializer feature from Pydantic), that allows us to simply remove warnings for those two models.

@shortcuts shortcuts self-assigned this Aug 29, 2025
@shortcuts shortcuts requested a review from a team as a code owner August 29, 2025 14:00
@algolia-bot
Copy link
Collaborator

algolia-bot commented Aug 29, 2025

✔️ Code generated!

Name Link
🪓 Triggered by 9e998d86e9578e0691934f6c69b89e7cf2efa3cd
🍃 Generated commit eac8e8ccb915adef2fd076662cd06f619bb0be1f
🌲 Generated branch generated/fix/python-highlight-snippet-result-warnings
📊 Benchmark results

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

Language Req/s
go 1776
javascript 1663
php 1470
csharp 1448
python 1146
java 1009
ruby 829
swift 588
scala 23

Copy link
Collaborator

@millotp millotp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice fix, we should never have infinite recursion, unless someone malicious forges the object

@shortcuts shortcuts enabled auto-merge (squash) September 1, 2025 15:07
@shortcuts shortcuts merged commit db05110 into main Sep 1, 2025
29 checks passed
@shortcuts shortcuts deleted the fix/python-highlight-snippet-result-warnings branch September 1, 2025 15:24
algolia-bot added a commit that referenced this pull request Sep 1, 2025
algolia-bot added a commit to algolia/algoliasearch-client-python that referenced this pull request Sep 1, 2025
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.

_highlightResult leads to serialization warnings

4 participants