This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 81462283eaf Assert the refusal log with getMessage so the compat tests
pass (#70905)
81462283eaf is described below
commit 81462283eafa6faf8db03376f6b7a2cb2918288a
Author: Jarek Potiuk <[email protected]>
AuthorDate: Sat Aug 1 16:39:46 2026 +0200
Assert the refusal log with getMessage so the compat tests pass (#70905)
The refusal-logging assertions in the Amazon secrets tests read record.msg
directly. How a record carries its payload depends on the Airflow version:
on
main, structlog renders the format args into msg before the stdlib record
exists,
so args is empty and msg holds the final text; on the versions the provider
compat tests run against, plain stdlib logging leaves msg as the format
string
with the values in args.
Reading msg therefore passes on main and fails under Compat 2.11.1 and
3.0.6,
which is where these currently break:
assert 0 == 1
where 0 = sum(refused_id in r.msg for r in refusals)
getMessage() renders in both shapes. The assertion still targets the
refused id
rather than the wording, so rephrasing the warning stays free.
Introduced in #70878, where the assertions were moved off getMessage and
verified
only against main.
---
.../tests/unit/amazon/aws/secrets/test_secrets_manager.py | 14 ++++++++------
.../tests/unit/amazon/aws/secrets/test_systems_manager.py | 14 ++++++++------
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git
a/providers/amazon/tests/unit/amazon/aws/secrets/test_secrets_manager.py
b/providers/amazon/tests/unit/amazon/aws/secrets/test_secrets_manager.py
index 5df7ee72d93..ab345a9f38d 100644
--- a/providers/amazon/tests/unit/amazon/aws/secrets/test_secrets_manager.py
+++ b/providers/amazon/tests/unit/amazon/aws/secrets/test_secrets_manager.py
@@ -142,10 +142,12 @@ class TestSecretsManagerBackend:
assert backend.get_variable(key="prod--hello") is None
assert backend.get_config(key="prod--sql_alchemy_conn") is None
- # Airflow logs through structlog, which renders the format args into
``msg`` before the
- # stdlib record is built -- ``record.args`` is empty, so there is no
structured payload
- # to assert on. Assert on level, logger and the refused id (the
load-bearing data)
- # rather than the wording, so rephrasing the warning does not break
this.
+ # ``getMessage()`` rather than ``msg``: how a record carries its
payload depends on the
+ # Airflow version. Here structlog renders the format args into ``msg``
before the stdlib
+ # record exists, so ``args`` is empty; on the versions the provider
compat tests run
+ # against, plain stdlib logging leaves ``msg`` as the format string
with the values in
+ # ``args``. ``getMessage()`` renders in both. Assert on level, logger
and the refused id
+ # (the load-bearing data) rather than the wording, so rephrasing the
warning is free.
refusals = [
r
for r in caplog.records
@@ -153,8 +155,8 @@ class TestSecretsManagerBackend:
]
assert len(refusals) == 3
for refused_id in ("prod--test_postgres", "prod--hello",
"prod--sql_alchemy_conn"):
- assert sum(refused_id in r.msg for r in refusals) == 1
- assert all(TEAM_SEP in r.msg for r in refusals)
+ assert sum(refused_id in r.getMessage() for r in refusals) == 1
+ assert all(TEAM_SEP in r.getMessage() for r in refusals)
@mock_aws
def test_team_caller_falls_back_to_global_connection(self):
diff --git
a/providers/amazon/tests/unit/amazon/aws/secrets/test_systems_manager.py
b/providers/amazon/tests/unit/amazon/aws/secrets/test_systems_manager.py
index ae1719a570b..09734819e13 100644
--- a/providers/amazon/tests/unit/amazon/aws/secrets/test_systems_manager.py
+++ b/providers/amazon/tests/unit/amazon/aws/secrets/test_systems_manager.py
@@ -185,10 +185,12 @@ class TestSsmSecrets:
assert backend.get_variable(key="prod--hello") is None
assert backend.get_config(key="prod--sql_alchemy_conn") is None
- # Airflow logs through structlog, which renders the format args into
``msg`` before the
- # stdlib record is built -- ``record.args`` is empty, so there is no
structured payload
- # to assert on. Assert on level, logger and the refused id (the
load-bearing data)
- # rather than the wording, so rephrasing the warning does not break
this.
+ # ``getMessage()`` rather than ``msg``: how a record carries its
payload depends on the
+ # Airflow version. Here structlog renders the format args into ``msg``
before the stdlib
+ # record exists, so ``args`` is empty; on the versions the provider
compat tests run
+ # against, plain stdlib logging leaves ``msg`` as the format string
with the values in
+ # ``args``. ``getMessage()`` renders in both. Assert on level, logger
and the refused id
+ # (the load-bearing data) rather than the wording, so rephrasing the
warning is free.
refusals = [
r
for r in caplog.records
@@ -196,8 +198,8 @@ class TestSsmSecrets:
]
assert len(refusals) == 3
for refused_id in ("prod--test_postgres", "prod--hello",
"prod--sql_alchemy_conn"):
- assert sum(refused_id in r.msg for r in refusals) == 1
- assert all(TEAM_SEP in r.msg for r in refusals)
+ assert sum(refused_id in r.getMessage() for r in refusals) == 1
+ assert all(TEAM_SEP in r.getMessage() for r in refusals)
@mock_aws
def test_team_caller_falls_back_to_global_connection(self):