Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [hono-dev] Validation of payload - where to do best?

Hi Karsten,

my take on this is as follows:

Perform checks on "exposed" message properties (e.g. address, standard properties, application properties) as early as possible and reject messages not meeting the requirments.

Defer checks regarding the content of the payload (syntax, semantics) to the component doing the actual processing of the content. IMHO we should not duplicate this kind of logic in two places in Hono.

I guess this is pretty much the strategy we are currently following in the code base.

Mit freundlichen Grüßen / Best regards

Kai Hudalla
Chief Software Architect

Bosch Software Innovations GmbH
Schöneberger Ufer 89-91
10785 Berlin

Registered office: Berlin, Register court: Amtsgericht Charlottenburg, HRB 148411 B;
Executives: Dr.-Ing. Rainer Kallenbach, Michael Hahn

From: hono-dev-bounces@xxxxxxxxxxx <hono-dev-bounces@xxxxxxxxxxx> on behalf of Frank Karsten (INST/ECS4) <Karsten.Frank2@xxxxxxxxxxxx>
Sent: Wednesday, May 17, 2017 14:51
To: hono-dev@xxxxxxxxxxx
Subject: [hono-dev] Validation of payload - where to do best?

Hi hono developers,


While implementing further details of the Hono credentials API, I wondered about where to add the validation checks of the payload of requests.


AMQP message properties are checked very “early”, meaning: that mandatory params are fully contained is checked directly when the AMQP message is received. In that case the message is not further worked on, IMHO the best solution.

If the message is ok, it is passed over to another verticle which “tries” to work on that message and generates the appropriate reply.


The questionable part is now the (JSON) payload – should it be fully checked directly when receiving the message, or should it be sent to the event bus and is checked when the worker verticle needs to access the data?


I would slightly prefer the later (check late in the worker verticle) but it is not as clear as if it was checked together with the message properties directly when receiving. On the other hand it eliminates double parsing of the JSON object.

But then : intentionally bad requests (wrong payload) could create more load to Hono than fully checking the message at the very beginning.


Any clear opinions on that topic?






Back to the top