Skip to content

Unable to use firestore.SERVER_TIMESTAMP #680

Open
@mirceatlx

Description

@mirceatlx

Environment

  • Operating System version: Windows 10 Pro 10.0.19045 Build 19045
  • Firebase SDK version: 6.1.0
  • Firebase Product: Firestore (auth, database, storage, etc)
  • Python version: 3.10.8
  • Pip version: 22.3.1

Steps to reproduce:

Trying to set the timestamp when creating or updating a Firestore with firestore.SERVER_TIMESTAMP but go error message TypeError: Not a cmessage.

Relevant Code:

from firebase_admin import credentials, firestore

cred = credentials.Certificate(...)
firebase_admin.initialize_app(cred)

client = firestore.client()
collection = client.collection('test')
u = uuid.uuid4()
collection.document(str(u)).set({
            'id': str(u),
            'timestamp': firestore.SERVER_TIMESTAMP
        })

Full error message:

"/opt/homebrew/Caskroom/miniforge/base/envs/apa/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/apa/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/Users/hiro/Documents/apa/src/backend/pipeline/pipeline.py", line 65, in run
    self.collection.document(str(self.uuid)).update({
  File "/opt/homebrew/Caskroom/miniforge/base/envs/apa/lib/python3.10/site-packages/google/cloud/firestore_v1/document.py", line 324, in update
    batch, kwargs = self._prep_update(field_updates, option, retry, timeout)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/apa/lib/python3.10/site-packages/google/cloud/firestore_v1/base_document.py", line 239, in _prep_update
    batch.update(self, field_updates, option=option)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/apa/lib/python3.10/site-packages/google/cloud/firestore_v1/base_batch.py", line 141, in update
    write_pbs = _helpers.pbs_for_update(
  File "/opt/homebrew/Caskroom/miniforge/base/envs/apa/lib/python3.10/site-packages/google/cloud/firestore_v1/_helpers.py", line 941, in pbs_for_update
    update_pb.update_transforms.extend(field_transform_pbs)
TypeError: Not a cmessage

Pip list environment

absl-py                  1.4.0
anyio                    3.6.2
appnope                  0.1.3
argon2-cffi              21.3.0
argon2-cffi-bindings     21.2.0
arrow                    1.2.3
astroid                  2.14.2
asttokens                2.2.1
astunparse               1.6.3
attrs                    22.2.0
backcall                 0.2.0
beautifulsoup4           4.11.1
bleach                   5.0.1
CacheControl             0.12.11
cached-property          1.5.2
cachetools               5.2.1
certifi                  2022.12.7
cffi                     1.15.1
charset-normalizer       3.0.1
comm                     0.1.2
contourpy                1.0.7
cryptography             39.0.2
cycler                   0.11.0
Cython                   0.29.33
debugpy                  1.6.5
decorator                5.1.1
defusedxml               0.7.1
dill                     0.3.6
entrypoints              0.4
exceptiongroup           1.1.0
executing                1.2.0
fastjsonschema           2.16.2
firebase-admin           6.1.0
flatbuffers              23.1.4
fonttools                4.38.0
fqdn                     1.5.1
gast                     0.4.0
google-api-core          2.11.0
google-api-python-client 2.80.0
google-auth              2.16.0
google-auth-httplib2     0.1.0
google-auth-oauthlib     0.4.6
google-cloud-core        2.3.2
google-cloud-firestore   2.10.0
google-cloud-storage     2.7.0
google-crc32c            1.5.0
google-pasta             0.2.0
google-resumable-media   2.4.1
googleapis-common-protos 1.58.0
grpcio                   1.51.3
grpcio-status            1.51.3
h5py                     3.6.0
httplib2                 0.21.0
idna                     3.4
iniconfig                2.0.0
ipykernel                6.20.2
ipython                  8.8.0
ipython-genutils         0.2.0
isoduration              20.11.0
isort                    5.12.0
jedi                     0.18.2
Jinja2                   3.1.2
jsonpointer              2.3
jsonschema               4.17.3
jupyter_client           7.4.9
jupyter_core             5.1.3
jupyter-events           0.6.3
jupyter_server           2.1.0
jupyter_server_terminals 0.4.4
jupyterlab-pygments      0.2.2
keras                    2.11.0
kiwisolver               1.4.4
lazy-object-proxy        1.9.0
libclang                 15.0.6.1
Markdown                 3.4.1
MarkupSafe               2.1.2
matplotlib               3.6.2
matplotlib-inline        0.1.6
mccabe                   0.7.0
mistune                  2.0.4
msgpack                  1.0.4
mypy                     1.0.1
mypy-extensions          1.0.0
nbclassic                0.4.8
nbclient                 0.7.2
nbconvert                7.2.8
nbformat                 5.7.3
nest-asyncio             1.5.6
notebook                 6.5.2
notebook_shim            0.2.2
numpy                    1.24.1
oauthlib                 3.2.2
opencv-python            4.7.0.68
opt-einsum               3.3.0
packaging                23.0
pandas                   1.5.2
pandocfilters            1.5.0
parso                    0.8.3
pexpect                  4.8.0
pickleshare              0.7.5
Pillow                   9.4.0
pip                      22.3.1
platformdirs             2.6.2
pluggy                   1.0.0
prometheus-client        0.15.0
prompt-toolkit           3.0.36
proto-plus               1.22.2
protobuf                 4.22.0
psutil                   5.9.4
ptyprocess               0.7.0
pure-eval                0.2.2
pyasn1                   0.4.8
pyasn1-modules           0.2.8
pycparser                2.21
pydash                   6.0.2
Pygments                 2.14.0
PyJWT                    2.6.0
pylint                   2.16.2
pyobjc-core              9.0.1
pyobjc-framework-Cocoa   9.0.1
pyparsing                3.0.9
pyrsistent               0.19.3
pytest                   7.2.1
python-dateutil          2.8.2
python-json-logger       2.0.4
pytz                     2022.7.1
PyYAML                   6.0
pyzmq                    25.0.0
requests                 2.28.2
requests-oauthlib        1.3.1
rfc3339-validator        0.1.4
rfc3986-validator        0.1.1
rsa                      4.9
screeninfo               0.8.1
Send2Trash               1.8.0
setuptools               66.1.0
six                      1.16.0
sniffio                  1.3.0
soupsieve                2.3.2.post1
stack-data               0.6.2
tensorboard              2.11.2
tensorboard-data-server  0.6.1
tensorboard-plugin-wit   1.8.1
tensorflow-estimator     2.11.0
tensorflow-macos         2.11.0
termcolor                2.2.0
terminado                0.17.1
tinycss2                 1.2.1
tomli                    2.0.1
tomlkit                  0.11.6
tornado                  6.2
traitlets                5.8.1
typing_extensions        4.4.0
uri-template             1.2.0
uritemplate              4.1.1
urllib3                  1.26.14
wcwidth                  0.2.6
webcolors                1.12
webencodings             0.5.1
websocket-client         1.4.2
Werkzeug                 2.2.2
wheel                    0.38.4
wrapt                    1.14.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions