Skip to content

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

Description

@jonathanberthias

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions