dapr/rust-sdk

Bug: Pubsub function parameter does not allow additional colons

ruokun-niu opened this issue · 1 comments

Let us assume that I have defined the following pubsub function, where the input parameter is of type serde_json::Value

#[topic(pub_sub_name = "pubsub", topic = "A")]
async fn handle_a_event(order: serde_json::Value) {
    println!("Topic A - {:#?}", order)
}

When I run cargo build, I got the following error

error: custom attribute panicked
   --> src/main.rs:111:1
    |
111 | #[topic(pub_sub_name = "rg-pubsub", topic = "A")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: message: assertion `left == right` failed: Expected to only have one input variable
              left: 2
             right: 1

However, if I import serde_json::Value ahead of the time and use Value instead, no errors will be thrown

use serde_json::Value;
#[topic(pub_sub_name = "pubsub", topic = "A")]
async fn handle_a_event(order: Value) {
    println!("Topic A - {:#?}", order)
}

I believe this might be due to how we are parsing the input variable in the macros here?

Expected Behavior

The macro is only checking to see if there is only one input parameter. We should not be getting any errors if we use serde_json::Value instead of Value

Actual Behavior

Listed above

Steps to Reproduce the Problem

Release Note

RELEASE NOTE:

Great spot, the variable parsing logic for this macro should be updated.