novuhq / novu

Open-Source Notification Platform. Embeddable Notification Center, E-mail, Push and Slack Integrations.
https://novu.co
Other
34.46k stars 3.51k forks source link

🐛 Bug Report: Triggering an Event might lead to an outdated Error Messages (when using outdated request) #4891

Closed JonasDoe closed 9 months ago

JonasDoe commented 9 months ago

📜 Description

When triggering an Event with an outdated request structure, I get an error suggesting the outdates request structure is still expected. Here's a sketch:

{
    "name": "{{workflow}}",
    "to": [{
        "type": "Topic",
        "topicKey": "{{topicKey}}"    
    }],
    "payload": {
      "customVariables": "Hello World",
      "from": "Trigger event"
    },
    "transactionId": "{{triggerEventTransactionId}}",
    "actor": {
        "subscriberId:": "{{subscriberIdTest}}",
    }
  }

The actor is invalid, according to the documentation it should be a string, not an object. The error response still suggests otherwise, though:

{
    "message": [
        "actor.subscriberId should not be null or undefined",
        "actor.subscriberId must be a string"
    ],
    "error": "Bad Request",
    "statusCode": 400
}

👟 Reproduction steps

Just run a POST request against /events/trigger which is valid except for the actor.

👍 Expected behavior

I'ld expect an error response like

{
    "message": [
        "actor must be a string"
    ],
    "error": "Bad Request",
    "statusCode": 400
}

👎 Actual Behavior with Screenshots

image

Novu version

NOVU self-hosted v0.21.0

npm version

No response

node version

No response

📃 Provide any additional context for the Bug.

No response

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

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

None

jainpawan21 commented 9 months ago

Hi @JonasDoe I see you are using postman variables as value in actor.subscriberId. Could you double check if jwt_test is a valid string or not. You can check postman console of request and response.

JonasDoe commented 9 months ago

Hey, I found out my request was actually faulty - the core issue was that I used "subscriberId:" instead of "subscriberId". Now, it's actually working. Sry for the fuzz! What I don't get is why the documentation claims it must be a string. Are both approaches supported, and one of them is a deprecated variant?

JonasDoe commented 9 months ago

Well, either I was blind before, or it was fixed later. But I see that the documenation now reflects both cases - subscriberId being a string or an object (now?). :)