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.
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)) }
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:
Java's native
String.CASE_INSENSITIVE_ORDERinternally triggersCharacter.toLowerCase(). On a Turkish host machine, this converts the capital letterIin"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.
Suggested Official Fix
The
TreeMapshould enforce a locale-invariant comparator (such asLocale.ROOT) to guarantee strict ASCII/English-based casing rules across all operating systems: