`RedactUrlQueryParamsFilter` crashes with `TypeError: NoneType is not iterable` when MLflow's urllib3 filter runs first
還沒有人認領這個 Issue。
評估
研究方向
從 databricks/sql/init.py 中第 51 行附近的 RedactUrlQueryParamsFilter 設定開始,接著檢查第 39 行附近的篩選器邏輯。先匯入 MLflow,再執行最小 logging 重現,並檢查無 args 路徑和 dict-args 路徑。完成標準是,帶有認證資訊的 URL 記錄不再引發 TypeError 或 AttributeError。
由索引模型根據 Issue 內容生成。
描述
RedactUrlQueryParamsFilter is attached to the global urllib3.connectionpool logger at import (databricks/sql/__init__.py:51). Its filter() iterates record.args with no None guard:
else:
record.args = tuple(
(self.redact(arg) if isinstance(arg, str) else arg)
for arg in record.args # TypeError when record.args is None
)
Normal logging never sets record.args = None (an args-less call yields ()), so this looks safe in isolation. But MLflow attaches its own credential-redaction filter to the same logger (SensitiveQueryParamFilter), and when it redacts a URL it explicitly nulls the args:
if redacted != message:
record.msg = redacted
record.args = None
When both libraries are imported (MLflow first, so its filter runs first), any urllib3.connectionpool record carrying a credentialed URL, e.g. logged on a connection retry, is redacted by MLflow, which sets record.args = None, and then RedactUrlQueryParamsFilter crashes on it.
Minimal repro
import logging, mlflow, databricks.sql
logging.getLogger("urllib3.connectionpool").warning(
"GET %s", "https://bucket.s3/obj?X-Amz-Signature=deadbeef"
)
# TypeError: 'NoneType' object is not iterable
Real-world trigger: MLflow search_traces(..., include_spans=True) against a Databricks tracking store, on a retry of a presigned/credentialed URL during span loading.
Two bugs in the filter:
for arg in record.argshas noNoneguard- Line 39,
record.arg[k]should berecord.args[k]: anAttributeErrorin the dict-args branch.
Both of these would have been caught with a basic type annotation for the record argument.
Version
databricks-sql-connector==4.4.0; unchanged on main.
- 主要語言
- Python
- 星號
- 233
- 分支
- 152
- 平均合併
- 21 小時 5 分鐘
- 30 天內合併 PR
- 10
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
databricks/databricks-sql-python 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
-
難度 2/5 1-3 小時 新手友好度 78/100
-
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1-3 小時 新手友好度 84/100
-
engineer-bot
難度 2/5 1-3 小時 新手友好度 76/100
databricks/databricks-sql-python#860 · 3 則留言 ·
查看 databricks/databricks-sql-python 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 88/100
-
難度 2/5 1-3 小時 新手友好度 82/100
-
難度 2/5 1-3 小時 新手友好度 78/100
-
enhancement
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1-3 小時 新手友好度 74/100