zserio icon indicating copy to clipboard operation
zserio copied to clipboard

Missing request body validity check

Open kancve opened this issue 2 years ago • 1 comments

Example: In the generated service class:

class Service(zserio.ServiceInterface):
def _get_layer_by_tile_id_method(self, request_data: bytes, context: typing.Any) -> zserio.ServiceData:
    reader = zserio.BitStreamReader(request_data)
    request = ndslive.core.types.tile_id.TileId.from_reader(reader)
 return zserio.service.ObjectServiceData(self._get_layer_by_tile_id_impl(request, context))

If the parameter(request_data) is an outlier or null value, an exception will be thrown. Is there an optimization solution?

kancve avatar Oct 16 '23 09:10 kancve

If I got it correctly, answer is yes, we consistently do not implement any argument validity check in python.

The main reason is that we use type annotations and mypy. This gives us all the benefits of static type checking, and does not generally require any further explicit check in code with some performance penalty.

mikir avatar Oct 16 '23 12:10 mikir