Netreceiver: Unimplemented pin value interacts badly with payload size error
When receiving an unimplemented binary or text pin, netreceiver interprets a -1 value as an invalid payload size and returns "'er':'InvalidPayloadSize'". In this case this error doesn't explain what is happening.
netreceiver/main.py:1644
if size <= 0 or len(body) < offset + size or size > CONST['maxBlob']:
logging.debug("Invalid binary data, size=%d, len(body)=%d" % (size, len(body)))
return 'InvalidPayloadSize'
Maybe if these were separated into different conditions, particularly size=-1 being a special case to indicate that this is an unimplemented pin.
Could also split len(body) < offset + size
to give short payload and size > CONST['maxBlob']
to give long payload errors.
Comments (6)
-
-
It happens because of this when netsender is being asked for T1 in Jack's test, but a log is not ready.
-
The client logic still seems off to me as sds.ReadSystem is only supposed to be called for software-defined sensors, i.e., X pins.
Regardless, I'll factor out InvalidValue from InvalidPayloadSize as suggested.
-
@ausocean has this one been resolved ?
-
There are now separate errors InvalidValue and InvalidPayloadSize. Further, NetSender now returns an error of type netsender.ServerError for all errors originating from the server (as distinct from client-side errors).
-
- changed status to resolved
Fixed some time ago, but tested and confirmed for sure in https://bitbucket.org/ausocean/iot/commits/092a7e78e07e3f157d67b2cafdb0493b5a9efd3c
- Log in to comment
I don't think clients should be sending pin values of -1 in the first place, but if they do, I agree the error message could be more specific.