Bug: Turkish Locale - Potential Header/Key resolution failure due to case-insensitive TreeMap serialization

未关闭 适合新手
#755 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
kotlin
领域
api

调研方向

从 openai-java-core/src/main/kotlin/com/openai/core/http/Headers.kt 中的 TreeMap 初始化处开始。在土耳其语操作系统区域设置下复现标头查找或令牌解析,并验证比较不受区域设置影响。当无论主机区域设置如何,OpenAI-Organization 等标准标头都能一致解析时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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)) }
主要语言
Kotlin
星标
1.5k
派生
264
平均合并
13 小时 31 分钟
30 天内合并 PR
89

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

openai/openai-java 的其他 Issue

查看 openai/openai-java 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。