Skip to content

Commit 9497cb4

Browse files
committed
fix(auth): revert mTLS auto-enablement configuration warnings to debug level
1 parent 05b0d64 commit 9497cb4

1 file changed

Lines changed: 9 additions & 20 deletions

File tree

packages/google-auth/google/auth/transport/_mtls_helper.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@
5151
_LOGGER = logging.getLogger(__name__)
5252

5353

54-
# A flag to track if we have already logged a warning about mTLS auto-enablement failures.
55-
# This prevents log spam when client libraries create transports or session instances
56-
# frequently within a single process.
57-
_has_logged_mtls_warning = False
58-
59-
6054
_PASSPHRASE_REGEX = re.compile(
6155
b"-----BEGIN PASSPHRASE-----(.+)-----END PASSPHRASE-----", re.DOTALL
6256
)
@@ -737,7 +731,6 @@ def check_use_client_cert():
737731
Returns:
738732
bool: Whether the client certificate should be used for mTLS connection.
739733
"""
740-
global _has_logged_mtls_warning
741734
env_override = _check_use_client_cert_env()
742735
if env_override is not None:
743736
return env_override
@@ -752,13 +745,11 @@ def check_use_client_cert():
752745
with open(cert_path, "r") as f:
753746
content = json.load(f)
754747
except (FileNotFoundError, OSError, json.JSONDecodeError) as e:
755-
if not _has_logged_mtls_warning:
756-
_LOGGER.warning(
757-
"mTLS auto-enablement failed: Could not read/parse certificate file at %s. Error: %s",
758-
cert_path,
759-
e,
760-
)
761-
_has_logged_mtls_warning = True
748+
_LOGGER.debug(
749+
"mTLS auto-enablement failed: Could not read/parse certificate file at %s. Error: %s",
750+
cert_path,
751+
e,
752+
)
762753
return False
763754

764755
# Structural validation
@@ -768,12 +759,10 @@ def check_use_client_cert():
768759
return True
769760

770761
# If we got here, the file exists but the expected structure is missing
771-
if not _has_logged_mtls_warning:
772-
_LOGGER.warning(
773-
"mTLS auto-enablement failed: Certificate configuration file at %s is missing the required ['cert_configs']['workload'] section.",
774-
cert_path,
775-
)
776-
_has_logged_mtls_warning = True
762+
_LOGGER.debug(
763+
"mTLS auto-enablement failed: Certificate configuration file at %s is missing the required ['cert_configs']['workload'] section.",
764+
cert_path,
765+
)
777766
return False
778767

779768

0 commit comments

Comments
 (0)