Skip to content

pubsub messages are twice base64 encoded when using GAX #2577

@ericbuehl

Description

@ericbuehl

I am using a recent master (85a0c1a)

Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 12:54:16) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

$ pip show google-cloud-pubsub

---
Metadata-Version: 2.0
Name: google-cloud-pubsub
Version: 0.20.0+85a0c1a
Summary: Python Client for Google Cloud Pub/Sub
Home-page: https://github.com/GoogleCloudPlatform/google-cloud-python
Author: Google Cloud Platform
Author-email: jjg+google-cloud-python@google.com
Installer: pip
License: Apache 2.0
Location: /Users/eric/env/lib/python2.7/site-packages
Requires: google-cloud-core, grpc-google-pubsub-v1, gapic-google-pubsub-v1, grpcio, google-gax
Classifiers:
  Development Status :: 4 - Beta
  Intended Audience :: Developers
  License :: OSI Approved :: Apache Software License
  Operating System :: OS Independent
  Programming Language :: Python :: 2
  Programming Language :: Python :: 2.7
  Programming Language :: Python :: 3
  Programming Language :: Python :: 3.4
  Programming Language :: Python :: 3.5
  Topic :: Internet

To demonstrate this issue, I set up a simple pubsub push endpoint that prints the posted data.

$ python
>>> from google.cloud import pubsub
>>> pubsub.Client("myproject").topic("mytopic").publish("blah")

Data received at push endpoint:

{u'message': {u'attributes': {},
              u'data': u'WW14aGFBPT0=',
...

$ GOOGLE_CLOUD_DISABLE_GRPC=1 python
>>> from google.cloud import pubsub
>>> pubsub.Client("myproject").topic("mytopic").publish("blah")

Data received at push endpoint:

{u'message': {u'attributes': {},
              u'data': u'YmxhaA==',
...

As you can see, the data in the first version is a twice-encoded version of the message "blah" while GAX is in use. I would expect to see the latter regardless of GAX being enabled or not.


(Added by @dhermes)

>>> import base64
>>> base64.b64decode(u'WW14aGFBPT0=')
'YmxhaA=='
>>> base64.b64decode('YmxhaA==')
'blah'

Metadata

Metadata

Assignees

Labels

api: pubsubIssues related to the Pub/Sub API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions