Description
[REQUIRED] Environment info
firebase-tools: 12.2.0
Platform: Mac M1, running linux devcontainer
[REQUIRED] Test case
I tested the sample firestore function code from firebase-functions-python library with the emulator (v1.17.4) and the event trigger with the library was failed, because of the wrong timestamp format in CloudEvent object.
Current version of the spec is v1.0.2 says the Timestamp format is RFC 3339 - it should match with %Y-%m-%dT%H:%M:%S.%f%z
. From the logs the emulator CloudEvent trigger timestamp is 2023-05-24T18:33:00.900823421Z
and the fractional seconds component 900823421
exceeds the six-digit limit specified by the RFC.
This is my previous test result, first opened an issue on python library side: firebase/firebase-functions-python#95 (comment)
[REQUIRED] Steps to reproduce
Use firebase-functions-python basic firestore sample, run the emulator and create a hello
document.
[REQUIRED] Expected behavior
Matching timestamp format
[REQUIRED] Actual behavior
[debug] [2023-05-24T18:33:00.921Z] [work-queue] {"queuedWork":["/functions/projects/trmc-test/triggers/europe-west1-onfirestoredocumentwritten-0-2023-05-24T18:33:00.920Z"],"queueLength":1,"runningWork":[],"workRunningCount":0}
[debug] [2023-05-24T18:33:00.921Z] [work-queue] {"queuedWork":[],"queueLength":0,"runningWork":["/functions/projects/trmc-test/triggers/europe-west1-onfirestoredocumentwritten-0-2023-05-24T18:33:00.920Z"],"workRunningCount":1}
[debug] [2023-05-24T18:33:00.922Z] Accepted request POST /functions/projects/trmc-test/triggers/europe-west1-onfirestoredocumentwritten-0 --> europe-west1-onfirestoredocumentwritten-0
[debug] [2023-05-24T18:33:00.923Z] [functions] Runtime ready! Sending request! {"metadata":{"emulator":{"name":"functions"},"message":"[functions] Runtime ready! Sending request!"}}
[debug] [2023-05-24T18:33:00.926Z] [functions] Got req.url=/functions/projects/trmc-test/triggers/europe-west1-onfirestoredocumentwritten-0, mapping to path=/functions/projects/ {"metadata":{"emulator":{"name":"functions"},"message":"[functions] Got req.url=/functions/projects/trmc-test/triggers/europe-west1-onfirestoredocumentwritten-0, mapping to path=/functions/projects/"}}
[debug] [2023-05-24T18:33:00.933Z] Running command with virtualenv: command=., args=["\"/workspaces/firebase-sample/cloud-functions/venv/bin/activate\"","&&","functions-framework"]
[debug] [2023-05-24T18:33:00.953Z] [worker-pool] addWorker(europe-west1-onfirestoredocumentwritten) {"metadata":{"emulator":{"name":"functions"},"message":"[worker-pool] addWorker(europe-west1-onfirestoredocumentwritten)"}}
[debug] [2023-05-24T18:33:00.955Z] [worker-pool] Adding worker with key europe-west1-onfirestoredocumentwritten, total=1 {"metadata":{"emulator":{"name":"functions"},"message":"[worker-pool] Adding worker with key europe-west1-onfirestoredocumentwritten, total=1"}}
[debug] [2023-05-24T18:33:01.070Z] May 24, 2023 6:33:01 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
{"metadata":{"emulator":{"name":"firestore"},"message":"May 24, 2023 6:33:01 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[debug] [2023-05-24T18:33:02.072Z] [worker-europe-west1-onfirestoredocumentwritten-256fb3eb-b43e-4da6-b004-2c509a272950]: IDLE {"metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"[worker-europe-west1-onfirestoredocumentwritten-256fb3eb-b43e-4da6-b004-2c509a272950]: IDLE"}}
[debug] [2023-05-24T18:33:02.073Z] [worker-pool] submitRequest(triggerId=europe-west1-onfirestoredocumentwritten) {"metadata":{"emulator":{"name":"functions"},"message":"[worker-pool] submitRequest(triggerId=europe-west1-onfirestoredocumentwritten)"}}
[info] i functions: Beginning execution of "europe-west1-onfirestoredocumentwritten" {"metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"Beginning execution of \"europe-west1-onfirestoredocumentwritten\""}}
[debug] [2023-05-24T18:33:02.074Z] [worker-europe-west1-onfirestoredocumentwritten-256fb3eb-b43e-4da6-b004-2c509a272950]: BUSY {"metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"[worker-europe-west1-onfirestoredocumentwritten-256fb3eb-b43e-4da6-b004-2c509a272950]: BUSY"}}
[info] > [2023-05-24 18:33:02,082] ERROR in app: Exception on /functions/projects/ [POST] {"user":"[2023-05-24 18:33:02,082] ERROR in app: Exception on /functions/projects/ [POST]","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m [2023-05-24 18:33:02,082] ERROR in app: Exception on /functions/projects/ [POST]"}}
[info] > Traceback (most recent call last): {"user":"Traceback (most recent call last):","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m Traceback (most recent call last):"}}
[info] > File "/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app {"user":" File \"/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/flask/app.py\", line 2190, in wsgi_app","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m File \"/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/flask/app.py\", line 2190, in wsgi_app"}}
[info] > response = self.full_dispatch_request() {"user":" response = self.full_dispatch_request()","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m response = self.full_dispatch_request()"}}
[info] > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ {"user":" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m ^^^^^^^^^^^^^^^^^^^^^^^^^^^^"}}
[info] > File "/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/flask/app.py", line 1486, in full_dispatch_request {"user":" File \"/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/flask/app.py\", line 1486, in full_dispatch_request","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m File \"/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/flask/app.py\", line 1486, in full_dispatch_request"}}
[info] > rv = self.handle_user_exception(e) {"user":" rv = self.handle_user_exception(e)","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m rv = self.handle_user_exception(e)"}}
[info] > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ {"user":" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"}}
[info] > File "/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request {"user":" File \"/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/flask/app.py\", line 1484, in full_dispatch_request","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m File \"/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/flask/app.py\", line 1484, in full_dispatch_request"}}
[info] > rv = self.dispatch_request() {"user":" rv = self.dispatch_request()","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m rv = self.dispatch_request()"}}
[info] > ^^^^^^^^^^^^^^^^^^^^^^^ {"user":" ^^^^^^^^^^^^^^^^^^^^^^^","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m ^^^^^^^^^^^^^^^^^^^^^^^"}}
[info] > File "/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request {"user":" File \"/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/flask/app.py\", line 1469, in dispatch_request","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m File \"/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/flask/app.py\", line 1469, in dispatch_request"}}
[info] > return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) {"user":" return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)"}}
[info] > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ {"user":" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"}}
[info] > File "/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/functions_framework/__init__.py", line 174, in view_func {"user":" File \"/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/functions_framework/__init__.py\", line 174, in view_func","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m File \"/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/functions_framework/__init__.py\", line 174, in view_func"}}
[info] > function(event) {"user":" function(event)","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m function(event)"}}
[info] > File "/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/firebase_functions/firestore_fn.py", line 208, in on_document_written_wrapped {"user":" File \"/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/firebase_functions/firestore_fn.py\", line 208, in on_document_written_wrapped","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m File \"/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/firebase_functions/firestore_fn.py\", line 208, in on_document_written_wrapped"}}
[info] > return _firestore_endpoint_handler( {"user":" return _firestore_endpoint_handler(","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m return _firestore_endpoint_handler("}}
[info] > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ {"user":" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m ^^^^^^^^^^^^^^^^^^^^^^^^^^^^"}}
[info] > File "/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/firebase_functions/firestore_fn.py", line 114, in _firestore_endpoint_handler {"user":" File \"/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/firebase_functions/firestore_fn.py\", line 114, in _firestore_endpoint_handler","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m File \"/workspaces/firebase-sample/cloud-functions/venv/lib/python3.11/site-packages/firebase_functions/firestore_fn.py\", line 114, in _firestore_endpoint_handler"}}
[info] > event_time = _dt.datetime.strptime( {"user":" event_time = _dt.datetime.strptime(","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m event_time = _dt.datetime.strptime("}}
[info] > ^^^^^^^^^^^^^^^^^^^^^^ {"user":" ^^^^^^^^^^^^^^^^^^^^^^","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m ^^^^^^^^^^^^^^^^^^^^^^"}}
[info] > File "/usr/local/lib/python3.11/_strptime.py", line 568, in _strptime_datetime {"user":" File \"/usr/local/lib/python3.11/_strptime.py\", line 568, in _strptime_datetime","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m File \"/usr/local/lib/python3.11/_strptime.py\", line 568, in _strptime_datetime"}}
[info] > tt, fraction, gmtoff_fraction = _strptime(data_string, format) {"user":" tt, fraction, gmtoff_fraction = _strptime(data_string, format)","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m tt, fraction, gmtoff_fraction = _strptime(data_string, format)"}}
[info] > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ {"user":" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"}}
[info] > File "/usr/local/lib/python3.11/_strptime.py", line 349, in _strptime {"user":" File \"/usr/local/lib/python3.11/_strptime.py\", line 349, in _strptime","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m File \"/usr/local/lib/python3.11/_strptime.py\", line 349, in _strptime"}}
[info] > raise ValueError("time data %r does not match format %r" % {"user":" raise ValueError(\"time data %r does not match format %r\" %","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m raise ValueError(\"time data %r does not match format %r\" %"}}
[info] > ValueError: time data '2023-05-24T18:33:00.900823421Z' does not match format '%Y-%m-%dT%H:%M:%S.%f%z' {"user":"ValueError: time data '2023-05-24T18:33:00.900823421Z' does not match format '%Y-%m-%dT%H:%M:%S.%f%z'","metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"\u001b[90m> \u001b[39m ValueError: time data '2023-05-24T18:33:00.900823421Z' does not match format '%Y-%m-%dT%H:%M:%S.%f%z'"}}
[debug] [2023-05-24T18:33:02.092Z] Finishing up request with event=pause {"metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"Finishing up request with event=pause"}}
[info] i functions: Finished "europe-west1-onfirestoredocumentwritten" in 18.678208ms {"metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"Finished \"europe-west1-onfirestoredocumentwritten\" in 18.678208ms"}}
[debug] [2023-05-24T18:33:02.093Z] [worker-europe-west1-onfirestoredocumentwritten-256fb3eb-b43e-4da6-b004-2c509a272950]: IDLE {"metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"[worker-europe-west1-onfirestoredocumentwritten-256fb3eb-b43e-4da6-b004-2c509a272950]: IDLE"}}
[debug] [2023-05-24T18:33:02.093Z] Finishing up request with event=finish {"metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"Finishing up request with event=finish"}}
[debug] [2023-05-24T18:33:02.093Z] Finishing up request with event=close {"metadata":{"emulator":{"name":"functions"},"function":{"name":"europe-west1-onfirestoredocumentwritten"},"extension":{},"message":"Finishing up request with event=close"}}
[debug] [2023-05-24T18:33:02.093Z] [work-queue] {"queuedWork":[],"queueLength":0,"runningWork":[],"workRunningCount":0}
[debug] [2023-05-24T18:33:02.098Z] May 24, 2023 6:33:02 PM com.google.cloud.datastore.emulator.impl.events.FunctionsEmulatorEventPublisher sendHttpRequestV2
WARNING: Unsuccessful HTTP response when publishing v2 event for projects/trmc-test/eventarcTriggers/europe-west1-onfirestoredocumentwritten-0: 500 Internal Server Error
POST http://127.0.0.1:5001/functions/projects/trmc-test/triggers/europe-west1-onfirestoredocumentwritten-0
500 Internal Server Error: The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
{"metadata":{"emulator":{"name":"firestore"},"message":"May 24, 2023 6:33:02 PM com.google.cloud.datastore.emulator.impl.events.FunctionsEmulatorEventPublisher sendHttpRequestV2\nWARNING: Unsuccessful HTTP response when publishing v2 event for projects/trmc-test/eventarcTriggers/europe-west1-onfirestoredocumentwritten-0: 500 Internal Server Error\nPOST http://127.0.0.1:5001/functions/projects/trmc-test/triggers/europe-west1-onfirestoredocumentwritten-0\n500 Internal Server Error: The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.\n"}}
[debug] [2023-05-24T18:33:10.159Z] Received signal SIGINT (Ctrl-C) 1