question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error calling publish_event with rawPayload metadata

See original GitHub issue

Expected Behavior

Using the Python sample from the documentation to publish messages to a MQTT pub/sub binding with rawPayload=true :

from dapr.clients import DaprClient

with DaprClient() as d:
    req_data = {
        'order-number': '345'
    }
    # Create a typed message with content type and body
    resp = d.publish_event(
        pubsub_name='pubsub',
        topic='TOPIC_A',
        data=json.dumps(req_data),
        metadata=(
                     ('rawPayload', 'true')
                 )
    )
    # Print the request
    print(req_data, flush=True) 

Actual Behavior

The following error occurs and the data is not published:

== APP ==     resp = d.publish_event(
== APP ==   File "/home/vscode/.local/lib/python3.8/site-packages/dapr/clients/grpc/client.py", line 350, in publish_event
== APP ==     _, call = self._stub.PublishEvent.with_call(req, metadata=metadata)
== APP ==   File "/home/vscode/.local/lib/python3.8/site-packages/grpc/_channel.py", line 955, in with_call
== APP ==     state, call, = self._blocking(request, timeout, metadata, credentials,
== APP ==   File "/home/vscode/.local/lib/python3.8/site-packages/grpc/_channel.py", line 926, in _blocking
== APP ==     call = self._channel.segregated_call(
== APP ==   File "src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi", line 498, in grpc._cython.cygrpc.Channel.segregated_call
== APP ==   File "src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi", line 366, in grpc._cython.cygrpc._segregated_call
== APP ==   File "src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi", line 360, in grpc._cython.cygrpc._segregated_call
== APP ==   File "src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi", line 218, in grpc._cython.cygrpc._call
== APP ==   File "src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi", line 246, in grpc._cython.cygrpc._call
== APP ==   File "src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi", line 89, in grpc._cython.cygrpc._operate
== APP ==   File "src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi", line 64, in grpc._cython.cygrpc._BatchOperationTag.prepare
== APP ==   File "src/python/grpcio/grpc/_cython/_cygrpc/operation.pyx.pxi", line 37, in grpc._cython.cygrpc.SendInitialMetadataOperation.c
== APP ==   File "src/python/grpcio/grpc/_cython/_cygrpc/metadata.pyx.pxi", line 41, in grpc._cython.cygrpc._store_c_metadata
== APP == ValueError: too many values to unpack (expected 2)

Checking the source code at client.py the rawPayload metadata probably needs to be assigned to the metadata of the PublishEventRequest, which is not implemented.

 content_type = ""
        if data_content_type:
            content_type = data_content_type
        req = api_v1.PublishEventRequest(
            pubsub_name=pubsub_name,
            topic=topic_name,
            data=req_data,
            data_content_type=content_type)

        # response is google.protobuf.Empty
        _, call = self._stub.PublishEvent.with_call(req, metadata=metadata)

Steps to Reproduce the Problem

Run the sample code from the documentation. In the sample there is another small issue, that the parameter topic needs to be renamed to topic_name.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
wcs1onlycommented, Nov 18, 2021

v1.4.1 pushed, and docs fixed.

0reactions
wcs1onlycommented, Nov 18, 2021

Fix merged. This is a bad enough bug it warrants an out of band patch release. Will cut that shortly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Client
func NewClient() (client Client, err error) ... can be passed as option to PublishEvent to set rawPayload metadata.
Read more >
Pub/sub API reference
Metadata can be sent via query parameters in the request's URL. ... rawPayload, Boolean to determine if Dapr should publish the event ...
Read more >
The Skill Tester - Using Oracle Digital Assistant
These test cases are part of the skill's metadata and therefore persist ... Recording conversations is quicker and less error prone than ...
Read more >
Error trying to get metadata from url stream using java ...
I don't know this library and how FFmpegMediaMetadataRetriever#extractMetadata works. I suspect that the second call to mmr.
Read more >
HTMLMediaElement: loadedmetadata event - Web APIs | MDN
These examples add an event listener for the HTMLMediaElement's loadedmetadata event, then post a message when that event handler has ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found