`RedactUrlQueryParamsFilter` crashes with `TypeError: NoneType is not iterable` when MLflow's urllib3 filter runs first

未關閉 適合新手
#946 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
backend

研究方向

從 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:

  1. for arg in record.args has no None guard
  2. Line 39, record.arg[k] should be record.args[k]: an AttributeError in 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

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

databricks/databricks-sql-python 的其他 Issue

查看 databricks/databricks-sql-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。