Netreceiver: Unimplemented pin value interacts badly with payload size error

Issue #2 resolved
Jack Richardson created an issue

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)

  1. Alan Noble

    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.

  2. Alan Noble

    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.

  3. Alan Noble

    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).

  4. Log in to comment