`RedactUrlQueryParamsFilter` crashes with `TypeError: NoneType is not iterable` when MLflow's urllib3 filter runs first
まだ誰も着手していません。
評価
調査の方向性
databricks/sql/init.py の 51 行目付近にある RedactUrlQueryParamsFilter のセットアップから始め、39 行目付近のフィルターロジックを確認します。MLflow を先に import した状態で最小限の 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分
- マージ済み PR(30日)
- 10
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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