Bug: Turkish Locale - Potential Header/Key resolution failure due to case-insensitive TreeMap serialization
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 1.5k
- Forks
- 264
- Avg merge
- 9h 46m
- Merged PRs (30d)
- 96
Description
Bug Description
Applications utilizing this SDK on a Turkish OS locale face unexpected anomalies or token crashes during HTTP header parsing.
Root Cause
In openai-java-core/src/main/kotlin/com/openai/core/http/Headers.kt (Line 38), the headers map is initialized using a locale-dependent comparison mechanism:
private val map: MutableMap<String, MutableList<String>> =
TreeMap(String.CASE_INSENSITIVE_ORDER)
Java's native String.CASE_INSENSITIVE_ORDER internally triggers Character.toLowerCase(). On a Turkish host machine, this converts the capital letter I in "OpenAI-Organization" into a dotless ı, turning it into "openaı-organization".
This causes key lookup failures or broken token states when downstream interceptors (like OkHttp) process standard ASCII headers.
Related Upstream Issue
This is the Java/Kotlin ecosystem equivalent of the localization bug found in the Node SDK.
- Linked Node Issue: https://github.com/openai/openai-node/issues/1928
Suggested Official Fix
The TreeMap should enforce a locale-invariant comparator (such as Locale.ROOT) to guarantee strict ASCII/English-based casing rules across all operating systems:
TreeMap { s1, s2 -> s1.lowercase(java.util.Locale.ROOT).compareTo(s2.lowercase(java.util.Locale.ROOT)) }
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in openai-java-core/src/main/kotlin/com/openai/core/http/Headers.kt at the TreeMap initialization. Reproduce header lookup or token parsing under a Turkish OS locale and verify the comparison is locale-invariant. Done means standard headers such as OpenAI-Organization resolve consistently regardless of the host locale.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100