From 23a8ef201078718b78e057038bd05e394d59e153 Mon Sep 17 00:00:00 2001 From: Jonathan Berthias Date: Wed, 9 Sep 2026 13:18:50 +0200 Subject: [PATCH] Guard RedactUrlQueryParamsFilter against None args urllib3.connectionpool records can arrive with record.args set to None when another logging filter (e.g. MLflow's SensitiveQueryParamFilter) redacts the message and nulls args before this filter runs. Iterating None raised TypeError. Guard the tuple branch with an explicit None check. Also fix a latent typo in the dict-args branch: record.arg[k] should be record.args[k], which would raise AttributeError whenever a record carried dict args. Fixes #946 Signed-off-by: Jonathan Berthias --- src/databricks/sql/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/databricks/sql/__init__.py b/src/databricks/sql/__init__.py index c0b6afdc6..9e36582e4 100644 --- a/src/databricks/sql/__init__.py +++ b/src/databricks/sql/__init__.py @@ -30,16 +30,16 @@ def __init__(self): def redact(self, string): return re.sub(self.pattern, self.mask, str(string)) - def filter(self, record): + def filter(self, record: logging.LogRecord): record.msg = self.redact(str(record.msg)) if isinstance(record.args, dict): for k in record.args.keys(): record.args[k] = ( self.redact(record.args[k]) - if isinstance(record.arg[k], str) + if isinstance(record.args[k], str) else record.args[k] ) - else: + elif record.args is not None: record.args = tuple( (self.redact(arg) if isinstance(arg, str) else arg) for arg in record.args