firebase / firebase/firebase-functions-python

[Bug] stability_digest_payload_from_ce_payload fails with AttributeError: 'dict' object has no attribute 'split'

Open
#260 6 comments 0 reactions 0 assignees View on GitHub
bug unable to reproduce
Dominant language
Python
Stars
167
Forks
34
PR merge metrics
No merged PRs in 30d

Description

**Bug Description**
When using @crashlytics_fn.on_stability_digest_published(), the function fails with an AttributeError because digestDate is received as a dictionary (Firebase Timestamp object) instead of a string, but the SDK attempts to call .split() on it.

**Error Message**
AttributeError: 'dict' object has no attribute 'split'

**Full Stack Trace**
Exception on / [POST]
Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.11/site-packages/flask/app.py", line 1511, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.11/site-packages/flask/app.py", line 919, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.11/site-packages/flask/app.py", line 917, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.11/site-packages/flask/app.py", line 902, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.11/site-packages/functions_framework/execution_id.py", line 157, in wrapper
result = view_function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.11/site-packages/functions_framework/__init__.py", line 188, in view_func
function(event)
File "/layers/google.python.pip/pip/lib/python3.11/site-packages/firebase_functions/alerts/crashlytics_fn.py", line 293, in crashlytics_decorator_wrapped
func(crashlytics_event_from_ce(raw))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.11/site-packages/firebase_functions/private/_alerts_fn.py", line 243, in crashlytics_event_from_ce
return event_from_ce_helper(raw, CrashlyticsEvent)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.11/site-packages/firebase_functions/private/_alerts_fn.py", line 209, in event_from_ce_helper
"data": firebase_alert_data_from_ce(event_dict),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.11/site-packages/firebase_functions/private/_alerts_fn.py", line 175, in firebase_alert_data_from_ce
alert_payload = stability_digest_payload_from_ce_payload(alert_payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.11/site-packages/firebase_functions/private/_alerts_fn.py", line 136, in stability_digest_payload_from_ce_payload
digest_date=_util.timestamp_conversion(payload["digestDate"]),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.11/site-packages/firebase_functions/private/util.py", line 407, in timestamp_conversion
precision_timestamp = get_precision_timestamp(time)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.11/site-packages/firebase_functions/private/util.py", line 391, in get_precision_timestamp
_, s_fraction = time.split(".")
^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'split'

**Environment**
firebase-functions version: 0.5.0 (also happens in 0.4.x)
firebase-admin version:7.1.0
Python version: 3.11
Deployment environment: Google Cloud Functions (2nd gen)

Contributor guide

Open the contributing guide

Research direction

Start with stability_digest_payload_from_ce_payload in firebase_functions/private/_alerts_fn.py and follow its call to timestamp_conversion in firebase_functions/private/util.py. Reproduce the stability digest event using the dictionary-shaped digestDate shown in the report, then verify the event conversion completes without the AttributeError and produces the expected timestamp.

Written by the indexing model from the issue text.

Assessment

Tech stack
firebase, python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.