Skip to content

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

Open
@ruokun-niu

Description

@ruokun-niu

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:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions