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

オープン 初心者向け
#946 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

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:

  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分
マージ済み PR(30日)
10

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

databricks/databricks-sql-python のほかの issue

databricks/databricks-sql-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。