api_version tests fail on 5.7.0 after the custom code was reverted
还没有人认领这个 Issue。
评估
调研方向
Run uv run pytest tests/test_client.py -k api_version on v5.7.0, then compare the API-Version tests with the reverted changes in _base_client.py, _client.py, and _version.py. Check the referenced commits and Stainless configuration before deciding whether the feature should ship or the tests and generated symbol should be removed; done means the chosen direction is implemented consistently and all six tests pass or are removed.
由索引模型根据 Issue 内容生成。
描述
Confirm this is a Python library issue and not an underlying Cloudflare API issue.
- This is an issue with the Python library
Describe the bug
Six tests in tests/test_client.py fail on a clean checkout of v5.7.0:
FAILED tests/test_client.py::TestCloudflare::test_api_version_env_var
FAILED tests/test_client.py::TestCloudflare::test_api_version_omitted_when_empty
FAILED tests/test_client.py::TestCloudflare::test_api_version_rejects_invalid_format
FAILED tests/test_client.py::TestAsyncCloudflare::test_api_version_env_var
FAILED tests/test_client.py::TestAsyncCloudflare::test_api_version_omitted_when_empty
FAILED tests/test_client.py::TestAsyncCloudflare::test_api_version_rejects_invalid_format
6 failed, 152 passed, 2 skipped
The tests expect api_version to fall back to CLOUDFLARE_API_VERSION, an invalid
api_version to raise ValueError, and the API-Version header to be omitted when no
version is configured. Cloudflare.__init__ does none of those. It defaults api_version
to datetime.today().strftime("%Y-%m-%d") and always sends the header, so every request
advertises a value like 2026-09-20, which does not match the <date>.<channel> form the
tests describe.
4e822eb97 ("feat: add API-Version header support") added the implementation and the tests
together. ecdba2038 ("chore: revert api_version custom code") reverted the implementation
in _base_client.py, _client.py and _version.py but left the tests, and they have
failed since.
Part of the feature is still generated: 5618be901 ("Update bundle: brapi") put
__api_version__ = "" back into _version.py after the revert, so codegen still emits the
symbol while the code that read it is gone.
Was the revert intentional? If the API-Version header is not shipping, the tests should
go too. If it is shipping, the implementation needs to come back, and presumably from the
Stainless config rather than as edits to _client.py, since direct edits are what got
reverted. I have a local branch restoring the reverted code and can open a PR either way,
but I would rather know which direction is wanted first.
To Reproduce
git clone https://github.com/cloudflare/cloudflare-python && cd cloudflare-pythongit checkout v5.7.0uv sync --all-extrasuv run pytest tests/test_client.py -k api_version
Code snippets
>>> from cloudflare import Cloudflare
>>> from cloudflare._models import FinalRequestOptions
>>> c = Cloudflare(api_token="x")
>>> c._build_request(FinalRequestOptions(method="get", url="/foo")).headers["api-version"]
'2026-09-20'
OS
Linux
Python version
Python 3.14.6
Library version
cloudflare 5.7.0
- 主要语言
- Python
- 星标
- 509
- 派生
- 150
- 平均合并
- 3 小时 15 分钟
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
cloudflare/cloudflare-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
cloudflare/cloudflare-python#2747 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
cloudflare/cloudflare-python#2718 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
cloudflare/cloudflare-python#2692 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
cloudflare/cloudflare-python#2679 · 4 条评论 · 5 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 25/100
cloudflare/cloudflare-python#2742 ·
查看 cloudflare/cloudflare-python 的全部 Issue
相似的 Issue
-
triage/confirmed
难度 2/5 1-3 小时 新手友好度 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
难度 1/5 1 小时以内 新手友好度 92/100
NousResearch/hermes-agent#118866 ·
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
apache/cloudstack#14222 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
-
bug
难度 2/5 1-3 小时 新手友好度 82/100