zserio
zserio copied to clipboard
Missing request body validity check
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?
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.