Skip to content

Commit a02b001

Browse files
authored
Merge branch 'main' into feat/logger
2 parents b416ba3 + f463ed1 commit a02b001

File tree

1 file changed

+7
-4
lines changed
  • src/firebase_functions/private

1 file changed

+7
-4
lines changed

src/firebase_functions/private/util.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def _on_call_valid_body(request: _Request) -> bool:
114114
return False
115115

116116
# The body must have data.
117-
if request.json is None or "data" not in request.json:
117+
if "data" not in request.json:
118118
_logging.warning("Request body is missing data.", request.json)
119119
return False
120120

@@ -133,7 +133,7 @@ def _on_call_valid_body(request: _Request) -> bool:
133133
def _on_call_valid_method(request: _Request) -> bool:
134134
"""Make sure it's a POST."""
135135
if request.method != "POST":
136-
_logging.warning("Request has invalid method.", request.method)
136+
_logging.warning("Request has invalid method. %s", request.method)
137137
return False
138138
return True
139139

@@ -143,7 +143,7 @@ def _on_call_valid_content_type(request: _Request) -> bool:
143143
content_type: str | None = request.headers.get("Content-Type")
144144

145145
if content_type is None:
146-
_logging.warning("Request is missing Content-Type.", content_type)
146+
_logging.warning("Request is missing Content-Type.")
147147
return False
148148

149149
# If it has a charset, just ignore it for now.
@@ -340,7 +340,10 @@ def nanoseconds_timestamp_conversion(time: str) -> _dt.datetime:
340340
def is_precision_timestamp(time: str) -> bool:
341341
"""Return a bool which indicates if the timestamp is in nanoseconds"""
342342
# Split the string into date-time and fraction of second
343-
_, s_fraction = time.split(".")
343+
try:
344+
_, s_fraction = time.split(".")
345+
except ValueError:
346+
return False # If there's no decimal, it's not a nanosecond timestamp.
344347

345348
# Split the fraction from the timezone specifier ('Z' or 'z')
346349
s_fraction, _ = s_fraction.split(

0 commit comments

Comments
 (0)