Repository navigation
Closed
Labels
api: pubsubIssues related to the Pub/Sub API.
Description
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.
Activity
daspecster commentedon Oct 20, 2016
@ericbuehl thanks for the report!
I'm checking on this right now.
daspecster commentedon Oct 20, 2016
@dhermes & @tseaver, I'm not seeing how this is happening in our lib. I also don't see it happening in the GAPIC code either.
This seems to be the only place we encode the message.
ericbuehl commentedon Oct 20, 2016
If I had to guess, I would say that protobuf is responsible for the second encoding
daspecster commentedon Oct 20, 2016
@ericbuehl I was thinking the same thing.
@bjwatson do you happen to know if that changed recently?
bjwatson commentedon Oct 20, 2016
@daspecster We haven't changed our version of gRPC or protobuf in more than a month (probably not for two months). I'm not aware of any changes in GAPIC or GAX that would explain this. Do you have any thoughts @geigerj?
geigerj commentedon Oct 20, 2016
I am not aware of any base64 encoding happening at the GAPIC/GAX layer.
dhermes commentedon Oct 20, 2016
@bjwatson It may not be a change, it could just be something we've never noticed. From
google.protobuf.json_formatFkawala commentedon Oct 21, 2016
As a side note the double base64 did not occurs with version 0.18.3.
dhermes commentedon Oct 21, 2016
@Fkawala It most likely was, did you try running with gRPC installed / enabled. gRPC for Pub/Sub was supported in 0.18.3 and the double encoding happened because
google.protobufwas automatically converting bytes to base64.google.protobufhas been doing that longer than this project has existed.Fkawala commentedon Oct 21, 2016
@dhermes I made a MWE (see this gist) with gcloud 0.18.3, the subscription has a push endpoint, but I don't think its changes anything.
producer code:
Consumer code:
Result
dhermes commentedon Oct 21, 2016
@Fkawala Thanks for the great example, but it doesn't ever switch between transports. Check out this repro that uses them side-by-side. First
then in the interpreter create two clients (one for each transport) by lying to the
gcloud.pubsub.clientmodule:then create a topic/subscription pair bound to each client and create the topic / subscription and publish to the topic
Finally, read the published message from each client's subscription to see the difference
(Also don't forget to
gax_topic.delete(),gax_sub.delete()after.)tseaver commentedon Oct 21, 2016
0.18.3had the GAX transport as optional (off by default);0.19.0enabled it by default.Fkawala commentedon Oct 24, 2016
@dhermes Sorry I would have add a "how to run" file if it wasn't for DYN DDOS. Anyway, thanks to you and @tseaver for this useful explantation. Is there a chance for #2578 to be shipped in the next release ? Is there a schedule for the next release ?
daspecster commentedon Oct 24, 2016
@Fkawala I'm working on #2578 today actually. I was going to try and have it done yesterday but some family stuff came up.
Merge pull request #2578 from daspecster/dont-b64encode-pubsub-messag…
dhermes commentedon Oct 24, 2016
@Fkawala we don't have any plans on a release but can cut a release just for the Pub/Sub package. I'm not sure if
0.20.1would be appropriate or if0.21.0would be necessary.Fkawala commentedon Oct 24, 2016
@daspecster Thanks for this blazing fast fix !
@dhermes Either way, a release would be greatly appreciated over here.
Merge pull request googleapis#2578 from daspecster/dont-b64encode-pub…
Merge pull request #2578 from daspecster/dont-b64encode-pubsub-messag…
fix(docs): async samples missing await (#2577)
chore: librarian release pull request: 20260402T161941Z (#16539)