From a26db22d7e3d1fc0df9f30de2610ac36de5ab680 Mon Sep 17 00:00:00 2001 From: Eric Kalosa-Kenyon Date: Sat, 16 Sep 2023 10:09:52 -0400 Subject: [PATCH 1/2] fix the most egregious issue with the use of python logging --- src/firebase_functions/private/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/firebase_functions/private/util.py b/src/firebase_functions/private/util.py index 0dd2eaa..6e41248 100644 --- a/src/firebase_functions/private/util.py +++ b/src/firebase_functions/private/util.py @@ -133,7 +133,7 @@ def _on_call_valid_body(request: _Request) -> bool: def _on_call_valid_method(request: _Request) -> bool: """Make sure it's a POST.""" if request.method != "POST": - _logging.warning("Request has invalid method.", request.method) + _logging.warning("Request has invalid method. %s", request.method) return False return True From 08e8707d7f8032ffe61470f99387704b31f6bfab Mon Sep 17 00:00:00 2001 From: Eric Kalosa-Kenyon Date: Mon, 25 Sep 2023 22:24:12 -0400 Subject: [PATCH 2/2] fixed all occurrences in private/utils.py --- src/firebase_functions/private/util.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/firebase_functions/private/util.py b/src/firebase_functions/private/util.py index 6e41248..35abdc4 100644 --- a/src/firebase_functions/private/util.py +++ b/src/firebase_functions/private/util.py @@ -115,7 +115,7 @@ def _on_call_valid_body(request: _Request) -> bool: # The body must have data. if request.json is None or "data" not in request.json: - _logging.warning("Request body is missing data.", request.json) + _logging.warning("Request body is missing data: %s", request.json) return False extra_keys = { @@ -123,7 +123,7 @@ def _on_call_valid_body(request: _Request) -> bool: } if len(extra_keys) != 0: _logging.warning( - "Request body has extra fields: ", + "Request body has extra fields: %s", "".join(f"{key}: {value}," for (key, value) in extra_keys.items()), ) return False @@ -143,7 +143,7 @@ def _on_call_valid_content_type(request: _Request) -> bool: content_type: str | None = request.headers.get("Content-Type") if content_type is None: - _logging.warning("Request is missing Content-Type.", content_type) + _logging.warning("Request is missing Content-Type.") return False # If it has a charset, just ignore it for now. @@ -156,7 +156,7 @@ def _on_call_valid_content_type(request: _Request) -> bool: # Check that the Content-Type is JSON. if content_type.lower() != "application/json": - _logging.warning("Request has incorrect Content-Type.", content_type) + _logging.warning("Request has incorrect Content-Type: %s", content_type) return False return True @@ -273,7 +273,7 @@ def on_call_check_tokens(request: _Request,) -> _OnCallTokenVerification: errs.append(("Auth token was rejected.", log_payload)) if len(errs) == 0: - _logging.info("Callable request verification passed", log_payload) + _logging.info("Callable request verification passed: %s", log_payload) else: _logging.warning(f"Callable request verification failed: ${errs}", log_payload)