dapr / dapr/rust-sdk

Bug: Pubsub function parameter does not allow additional colons

Open
#172 3 comments 1 reaction 1 assignee Claimed by @immanuwell View on GitHub
bug help wanted P1
Dominant language
Rust
Stars
252
Forks
73
PR merge metrics
No merged PRs in 30d

Description

Let us assume that I have defined the following pubsub function, where the input parameter is of type `serde_json::Value`
```rust
#[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
```rust
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](https://github.com/ruokun-niu/rust-sdk/blob/master/macros/src/lib.rs#L174)?

## 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:

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.