Skip to content

GAX can't log nested structs #2552

@waprin

Description

@waprin

This is the root issue in #2521 , if we feel it's the same issue can just rename that one. But when using gax,

from google.cloud import logging
client = logging.Client()
logger = client.logger('errors')

payload = {
    'a': {
        'b': 'c',
    }
}
logger.log_struct(payload)

produces:

  File "e.py", line 22, in <module>
    logger.log_struct(payload)
  File "/Users/waprin/.virtualenvs/tasks/lib/python2.7/site-packages/google/cloud/logging/logger.py", line 226, in log_struct
    client.logging_api.write_entries([entry_resource])
  File "/Users/waprin/.virtualenvs/tasks/lib/python2.7/site-packages/google/cloud/logging/_gax.py", line 108, in write_entries
    entry_pbs = [_log_entry_mapping_to_pb(entry) for entry in entries]
  File "/Users/waprin/.virtualenvs/tasks/lib/python2.7/site-packages/google/cloud/logging/_gax.py", line 607, in _log_entry_mapping_to_pb
    entry_pb.json_payload[key] = value
  File "/Users/waprin/.virtualenvs/tasks/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.py", line 732, in __setitem__
    _SetStructValue(self.fields[key], value)
  File "/Users/waprin/.virtualenvs/tasks/lib/python2.7/site-packages/google/protobuf/internal/well_known_types.py", line 702, in _SetStructValue
    raise ValueError('Unexpected type')
ValueError: Unexpected type

Metadata

Metadata

Assignees

Labels

api: loggingIssues related to the Cloud Logging API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions