Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Typo: Duplicate header name in authentication error message

未关闭 适合新手
#3,962 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
88/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python

调研方向

从 src/openai/_client.py 中同步客户端约第 664 行和异步客户端约第 1428 行的位置开始,然后比较身份验证错误消息。按描述修正重复的 header 名称并移除不必要的嵌入引号,然后重现凭据缺失的情况,以确认最终消息。

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

描述


name: Typo bug report
about: Typo in authentication error message (duplicate "Authorization")
title: 'Typo: Duplicate header name in authentication error message'
labels: bug, documentation
assignees: ''

Confirm this is an issue with the Python library and not an underlying OpenAI API
  • This is an issue with the Python library
Describe the bug

There is a copy-paste typo in the _validate_headers error message in both the sync and async clients. The message says:

"Authorization or Authorization headers to be explicitly omitted"

But it should mention both supported auth headers: Authorization (Bearer tokens) and api-key (API key auth).

Looking at the X.509 auth code in src/openai/auth/_x509.py:66, the SDK actually checks for api-key, x-api-key, and proxy-authorization headers as well.

Locations

File: src/openai/_client.py

  1. Sync client, line 664:
raise TypeError(
    '"Could not resolve authentication method. Expected either api_key or admin_api_key to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted"'
)
  1. Async client, line 1428:
raise TypeError(
    '"Could not resolve authentication method. Expected either api_key or admin_api_key to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted"'
)
Proposed fix

Change the error message to correctly list the auth headers:

raise TypeError(
    "Could not resolve authentication method. Expected either api_key or admin_api_key to be set. Or for one of the `Authorization` or `api-key` headers to be explicitly omitted"
)

(Also note the original message has extra leading/trailing double quotes inside the string which is also unnecessary.)

To Reproduce

Call any API method without setting credentials and without explicitly omitting auth headers.

Library version

v2.x latest (main branch)

主要语言
Python
星标
31.7k
派生
5.8k
平均合并
2 天 10 小时
30 天内合并 PR
98

环境准备

从这里开始

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

openai/openai-python 的其他 Issue

查看 openai/openai-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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