Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Pubsub function parameter does not allow additional colons #172

Open
ruokun-niu opened this issue Apr 23, 2024 · 1 comment
Open

Bug: Pubsub function parameter does not allow additional colons #172

ruokun-niu opened this issue Apr 23, 2024 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed P1
Milestone

Comments

@ruokun-niu
Copy link
Contributor

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:

@mikeee mikeee added bug Something isn't working help wanted Extra attention is needed P1 labels Apr 24, 2024
@mikeee mikeee added this to the 1.14 milestone Apr 24, 2024
@mikeee
Copy link
Member

mikeee commented Apr 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed P1
Projects
None yet
Development

No branches or pull requests

2 participants