[Bug] REST catalog drop_table serializes purgeRequested as "True" instead of "true"

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

还没有人认领这个 Issue。

评估

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

调研方向

从 pyiceberg/catalog/rest/init.py 中的 RestCatalog.drop_table 开始,检查 issue 中建议的其他 params= 出现位置。复现该请求或运行相关的 REST catalog 检查,然后验证 purgeRequested 是否被序列化为小写的 true 或 false,并确认服务器接受它。

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

描述

Apache Iceberg version

None

Please describe the bug 🐞
### Description

`RestCatalog.drop_table()` passes a Python `bool` directly to `requests` query params. Python's `requests` library 
serializes `True` as the string `"True"` (capitalized). This violates the OpenAPI 3.0 specification for boolean 
query parameters and causes 400 errors on spec-compliant servers.

### Steps to Reproduce

```python
from pyiceberg.catalog import load_catalog

catalog = load_catalog("my_catalog", **{
    "type": "rest",
    "uri": "http://my-rest-catalog/iceberg",
    ...
})

catalog.drop_table("my_db.my_table", purge_requested=True)
# → 400 Bad Request

Evidence

Enabled wire-level logging via http.client.HTTPConnection.debuglevel = 1:
send: b'DELETE /iceberg/v1//namespaces/my_db/tables/my_table?purgeRequested=True HTTP/1.1\r\n...'

reply: 'HTTP/1.1 400 Bad Request\r\n'
header: x-amzn-errortype: purge_enabled
body: {"error":{"type":"BadRequestException","message":"purge_enabled: DropTable operation failed. OSS Tables only 
supports dropping tables with purge enabled."}}

The server receives purgeRequested=True (capital T) and does not interpret it as boolean true.

Root Cause

pyiceberg/catalog/rest/init.py, drop_table method (~line 1135):
def drop_table(self, identifier: str | Identifier, purge_requested: bool = False) -> None:
response = self._session.delete(
self.url(Endpoints.drop_table, prefixed=True, **self._split_identifier_for_path(identifier)),
params={"purgeRequested": purge_requested}, # Python bool True → requests serializes as "True"
)
Python's requests library calls str() on param values: str(True) → "True".

Why This Is a Bug

The Iceberg REST catalog OpenAPI spec (rest-catalog-open-api.yaml
(https://github.com/apache/iceberg/blob/main/open-api/rest-catalog-open-api.yaml)) defines purgeRequested as:
- name: purgeRequested
in: query
schema:
type: boolean
Per the specification chain:

"True" (capitalized) is not a valid serialization of a JSON boolean.

Suggested Fix
params={"purgeRequested": str(purge_requested).lower()},
Or more explicitly:
params={"purgeRequested": "true" if purge_requested else "false"},
Scope

This pattern may exist elsewhere in the REST catalog client. A grep for params={ in
pyiceberg/catalog/rest/init.py would identify other occurrences where Python bools are passed as query
parameters.

Environment

  • PyIceberg: 0.11.1
  • Python: 3.10.21
  • Server: Aliyun OSS Tables (Iceberg REST compatible, strictly validates boolean query params)
  • requests: 2.x (serializes bool via str())
Willingness to contribute
  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time
主要语言
Python
星标
1.1k
派生
589
平均合并
2 天 4 小时
30 天内合并 PR
72

贡献指南

这个仓库没有索引到贡献指南

从这里开始

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

apache/iceberg-python 的其他 Issue

查看 apache/iceberg-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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