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

Handling of broken JSON objects causes absent body #104

Closed
ptusch opened this issue Aug 31, 2017 · 2 comments
Closed

Handling of broken JSON objects causes absent body #104

ptusch opened this issue Aug 31, 2017 · 2 comments
Assignees

Comments

@ptusch
Copy link

ptusch commented Aug 31, 2017

Hi everyone,

seems like this library has an issue when you publish a broken object (application/json) using any rabbit client and the consume it with rabbot.

The handle method seems to be called nicely and I can access most of the messages' properties - except for the body.
I didn't expect an absent body as I didn't find anything in the documentation so I assume it's a bug for now.

Of course, there might be broken messages in the queue but if that happens and such a message is of Content Type application/json I expect either an error or an empty object body which I can validate neatly. Today I have to check the body's existence (yes, easy but unexpected) which might be undesirable.

Anyhow what do you guys think of it?
Should I PR you a fix?

I'd say we could either throw an error in the error mechanic or return an empty body.

Used Versions

  • rabbot: 1.1.0
  • node: 4.4.7
  • npm: 2.15.8

Sample Data

Here's some correct json:

{
"name": "samwell"
}

And some broken json (note the missing"):

{
"name:"samwell"
}
@arobson arobson self-assigned this Feb 18, 2018
@arobson
Copy link
Owner

arobson commented Feb 18, 2018

@ptusch - I've added some new behaviors to make this easier to handle. The high level explanation is here.

The behavior now is that messages that can't be deserialized will be rejected. To process these, you'll need a DLX bound to a DLQ marked as poison so that you can manage it all.

When it re-publishes the message, it will set a quarantined flag on the message and append .quarantined to the end of the topic. This will allow you to handle topics like #.quarantined to get all quarantined topics, my.topic.quarantined to get only bad messages for a specific topic or even my.topic.# to get the regular and quarantined messages and then use the flag to detect the bad messages.

@ptusch
Copy link
Author

ptusch commented Feb 23, 2018

Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants