Confirm this is a Python library issue and not an underlying Cloudflare API issue.
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.
4e822eb ("feat: add API-Version header support") added the implementation and the tests
together. ecdba20 ("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: 5618be9 ("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-python
git checkout v5.7.0
uv sync --all-extras
uv 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
Confirm this is a Python library issue and not an underlying Cloudflare API issue.
Describe the bug
Six tests in
tests/test_client.pyfail on a clean checkout of v5.7.0:The tests expect
api_versionto fall back toCLOUDFLARE_API_VERSION, an invalidapi_versionto raiseValueError, and theAPI-Versionheader to be omitted when noversion is configured.
Cloudflare.__init__does none of those. It defaultsapi_versionto
datetime.today().strftime("%Y-%m-%d")and always sends the header, so every requestadvertises a value like
2026-09-20, which does not match the<date>.<channel>form thetests describe.
4e822eb ("feat: add API-Version header support") added the implementation and the tests
together. ecdba20 ("chore: revert api_version custom code") reverted the implementation
in
_base_client.py,_client.pyand_version.pybut left the tests, and they havefailed since.
Part of the feature is still generated: 5618be9 ("Update bundle: brapi") put
__api_version__ = ""back into_version.pyafter the revert, so codegen still emits thesymbol while the code that read it is gone.
Was the revert intentional? If the
API-Versionheader is not shipping, the tests shouldgo 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 gotreverted. 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_versionCode snippets
OS
Linux
Python version
Python 3.14.6
Library version
cloudflare 5.7.0