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

Đang mở Phù hợp với người mới
#946 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu trong databricks/sql/init.py, tại phần thiết lập RedactUrlQueryParamsFilter quanh dòng 51, sau đó kiểm tra logic của filter quanh dòng 39. Chạy bản tái hiện logging tối thiểu với MLflow được import trước và kiểm tra cả đường dẫn không có args lẫn đường dẫn dict-args. Hoàn tất khi các bản ghi URL có thông tin xác thực không còn gây ra TypeError hoặc AttributeError.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
233
Fork
152
Merge trung bình
21 giờ 5 phút
Pull request đã merge (30 ngày)
10

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của databricks/databricks-sql-python

Tất cả issue của databricks/databricks-sql-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.