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

Open Beginner friendly
#946 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start in databricks/sql/init.py around the RedactUrlQueryParamsFilter setup at line 51, then inspect the filter logic around line 39. Run the minimal logging reproduction with MLflow imported first and check both the args-less and dict-args paths. Done means credentialed URL records no longer raise either TypeError or AttributeError.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Python
Stars
233
Forks
152
Avg merge
21h 5m
Merged PRs (30d)
10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from databricks/databricks-sql-python

All issues in databricks/databricks-sql-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.