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 Report: Triggering an event for multiple receivers fails when one of them is invalid #6572

Open
2 tasks done
JonasDoe opened this issue Sep 25, 2024 · 6 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@JonasDoe
Copy link

JonasDoe commented Sep 25, 2024

📜 Description

Update: I've posted an updated and more precise description of the error in a comment below.

Old description:
I trigger an event with this payload:

{
    "actor": "myTestActor",
    "name": "generic-message",
    "payload": {
        "myTestData": "hello"
    },
    "to": [
        {
            "type": "Topic",
            "topicKey": "myTopic"
        },
        {
            "type": "Subscriber",
            "subscriberId": "mySubscriber"
        }
    ],
}

mySubscriber will get a notification, subscribers to myTopic won't. Removing the second to entry won't help - the topic won't receive the event as long as to has the form of a list.

👟 Reproduction steps

  1. Create a topic named myExistingTopic and subscribe with a user to it.
  2. Run
curl --location 'https://api.notification.app.myCompany.cloud/v1/events/trigger' \
--header 'Authorization: ApiKey *******' \
--header 'Content-Type: application/json' \
--data '{
    "actor": "myTestActor",
    "name": "generic-message",
    "payload": {
        "myTestData": "hello"
    },
     "to": [
        {
            "type": "Topic",
            "topicKey": "myTopic"
        },
        {
            "type": "Subscriber",
            "subscriberId": "mySubscriber"
        }
    ],
}'

The response is 201 with

{
    "data": {
        "acknowledged": true,
        "status": "processed",
        "transactionId": "487f708e-4a37-4438-9ec8-87deb5510ee2"
    }
}
  1. See that the subscribers for myTopic didn't receive any messge, while the subscriber did. Furthermore, in the Novu Center's Activity Feed you won't see anything about myTopic.

👍 Expected behavior

The users subscribed to myTopic should receive a message about the triggered event.

👎 Actual Behavior with Screenshots

The users subscribed to myTopic doesn't receive a message about the triggered event.

Novu version

0.24.0

npm version

I cannot provide this information right now, but we're basically using ghcr.io/novuhq/novu/api:0.24.0

node version

20.11.1

📃 Provide any additional context for the Bug.

It seems like triggering an event for a topic works when it's not in an array. So

{
    ...
    "to": {
        "type": "Topic",
        "topicKey": "myTopic"
    }
}

will work.

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

None

@JonasDoe JonasDoe changed the title 🐛 Bug Report: Triggering an event for multiple topics fails if one toic does not exist 🐛 Bug Report: Triggering an event for multiple topics fails Sep 26, 2024
@JonasDoe
Copy link
Author

I realized it's probalbly not cause by the topic's existence but by the mere fact I'm passing multiple topics - adjusted the issue accordingly.

@jainpawan21
Copy link
Member

@JonasDoe

This is correct format

"to": [
        {
            "type": "Topic",
            "topicKey": "first-topic"
        },
        {
            "subscriberId": "hello-first-subscriber"
        }
    ]

@JonasDoe
Copy link
Author

JonasDoe commented Oct 7, 2024

@JonasDoe

This is correct format

"to": [
        {
            "type": "Topic",
            "topicKey": "first-topic"
        },
        {
            "subscriberId": "hello-first-subscriber"
        }
    ]

Oh, I see, Then the error is more what I thought first - once an entry is invalid, nothing will be sent. I've tested again, even this won't work:

...
"to": [
    {
        "type": "Topic",
        "topicKey": "first-topic"
    },
    {
        "type": "Topic",
        "topicKey": "non-existent-topic"
    },
]

So, subscribers of first-topic won't get anything if:

  • there's another topic which does not exist
  • there's a an unexpected key: Subscriber

In the first scenario I'ld expect to reveive a message from first-topic
In the second scenario I'ld expect either the same or get a 400-response telling me about an invalid API usage.

@jainpawan21
Copy link
Member

Yes you are right. if any entry is invalid. Notification is not delivered. This sounds like a bug.

@jainpawan21 jainpawan21 added bug Something isn't working and removed triage labels Oct 7, 2024
@BadriVishalPadhy
Copy link

@JonasDoe can u assign this issue to me

@JonasDoe JonasDoe changed the title 🐛 Bug Report: Triggering an event for multiple topics fails 🐛 Bug Report: Triggering an event for multiple receivers fails when one of them is invalid Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants