nasa/fprime-tools

StringType Crashes on "Too Long"

LeStarch opened this issue · 1 comments

F´ Version devel
Affected Component

Problem Description

StringType uses a non-existant value when validating strings. Thus it crashes when trying to validate rather than producing a proper message:

How to Reproduce

  1. Send a CMD_NO_OP_STRING of length longer than 40 in the GDS (version 2.0)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "fprime-gds/src/fprime_gds/flask/commands.py", line 122, in put
    self.sender.send_command(command, arg_list)
  File "prime-gds/src/fprime_gds/common/pipeline/standard.py", line 149, in send_command
    cmd_data = fprime_gds.common.data_types.cmd_data.CmdData(
  File "fprime-gds/src/fprime_gds/common/data_types/cmd_data.py", line 70, in __init__
    self.convert_arg_value(val, typ)
  File "fprime-gds/src/fprime_gds/common/data_types/cmd_data.py", line 184, in convert_arg_value
    arg_type.val = arg_val
  File "fprime-tools/src/fprime/common/models/serialize/type_base.py", line 82, in val
    self.validate(val)
  File "fprime-tools/src/fprime/common/models/serialize/string_type.py", line 40, in validate
    raise StringSizeException(len(self.val), self.__max_string_len)
TypeError: object of type 'NoneType' has no len()

Note: the fix is to replace self.val with val