Skip to content

Conversation

reneemundie
Copy link
Contributor

🧭 What and Why

Fixes a concurrency issue in the generated C# client (HttpRequestHeadersExtensions.Fill) where a shared IDictionary<string, string> is enumerated without being cloned. This causes intermittent InvalidOperationException under load when the collection is modified during enumeration.

🎟 JIRA Ticket: https://algolia.atlassian.net/browse/DI-3456

Changes included:

  • Clone the dictionary with .ToList() before enumeration to prevent unsafe concurrent iteration

🧪 Test

  • Verified this change compiles in local environment
  • Fix has already been validated against the customer case and linked GitHub issue (algoliasearch-client-csharp#865)
  • Safe, non-breaking change

@reneemundie reneemundie requested a review from a team as a code owner May 6, 2025 05:37
@millotp millotp changed the title Fix InvalidOperationException in C# Fill() due to unsafe dictionary enumeration fix(clients): InvalidOperationException in C# Fill() due to unsafe dictionary enumeration May 6, 2025
Copy link
Contributor

@morganleroi morganleroi left a comment

Choose a reason for hiding this comment

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

thanks!

@millotp millotp merged commit d6e67a4 into algolia:main May 12, 2025
3 checks passed
algolia-bot added a commit to algolia/algoliasearch-client-csharp that referenced this pull request May 12, 2025
…ctionary enumeration (generated)

algolia/api-clients-automation#4820

Co-authored-by: Renée Mundie <[email protected]>
Co-authored-by: Renee Mundie <[email protected]>
Co-authored-by: Morgan Leroi <[email protected]>
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