Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting unencoded data from Google cloud Pub/Sub instead of base64

I'm attempting to use the Python library for Pub/Sub, but I keep getting this error: TypeError: Incorrect padding. Some quick googling revealed this issue: https://github.com/GoogleCloudPlatform/google-cloud-python/pull/2527

However, this doesn't resolve the issue - in fact, printing out the data revealed that the data was not even base64 encoded at all, and setting data = raw_data in the library resolved the issue.

We're sending the message from Java, here is the code we're using:

PCollection<String> userActionsJson = userActionsRaw.apply(ParDo.of(new BigQueryRowToJson()));
       String topicNameFull = "projects/" + options.getProject() + "/topics/" +
               options.getUsersActionsTopicName() + "-" + options.getProduct();
       userActionsJson.apply(PubsubIO.Write.named("PublishToPubSub")
               .topic(topicNameFull));

however, the same thing happens attempting to send a message through the console.

Has something changed recently to mean that data is no longer base64 encoded?

like image 215
daoudc Avatar asked Oct 18 '16 14:10

daoudc


People also ask

How does pub/sub deliver messages to endpoints?

The Pub/Sub server sends each message as an HTTPS request to the subscriber client at a pre-configured endpoint. This request is shown as a PushRequest in the image. The endpoint acknowledges the message by returning an HTTP success status code. A non-success response indicates that Pub/Sub must resend the messages.

How do I get my Pubsub verification token?

To create the token, Pub/Sub must call an internal Google service using a separate signing service account identity, which is the Google-managed service account service-${PROJECT_NUMBER}@gcp-sa-pubsub.iam.gserviceaccount.com . This signing service account must have the iam.


1 Answers

This was an issue that has now been resolved in master: https://github.com/GoogleCloudPlatform/google-cloud-python/issues/2577

like image 110
daoudc Avatar answered Oct 22 '22 02:10

daoudc