Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError on determining field size #606

Closed
treiher opened this issue Mar 12, 2021 · 2 comments · Fixed by #610
Closed

AttributeError on determining field size #606

treiher opened this issue Mar 12, 2021 · 2 comments · Fixed by #610
Assignees
Labels
bug pyrflx Related to pyrflx package (Legacy Python API)

Comments

@treiher
Copy link
Collaborator

treiher commented Mar 12, 2021

% tools/validate_spec.py -s dhcp.rflx -m DHCP::Message -v tests/data/dhcp/message/valid
tests/data/dhcp/message/valid/DHCP_MessageType_10,11,12_and_13_4.raw: FAILED
FalseNegative
pyrflx: error: cannot set value for field Htype
pyrflx: error: Number 0 is not a valid enum value

Traceback (most recent call last):
  File "tools/validate_spec.py", line 334, in <module>
    sys.exit(cli(sys.argv))
  File "tools/validate_spec.py", line 82, in cli
    validation_main(args)
  File "tools/validate_spec.py", line 135, in validation_main
    validation_result = validator.validate_message(msg)
  File "tools/validate_spec.py", line 200, in validate_message
    parser_result = self.__parse_message(original_message.bytes)
  File "tools/validate_spec.py", line 228, in __parse_message
    pdu_model.parse(message)
  File "[...]/lib/python3.7/site-packages/rflx/pyrflx/typevalue.py", line 736, in parse
    current_field_size = size.value
AttributeError: 'NoneType' object has no attribute 'value'

The used specification and test data can be found here.

@rssen Could you please take a look at it?

@treiher treiher added bug pyrflx Related to pyrflx package (Legacy Python API) labels Mar 12, 2021
@treiher treiher added this to To do in RecordFlux 0.5 via automation Mar 12, 2021
@rssen
Copy link
Contributor

rssen commented Mar 18, 2021

The problem is that Message'Last in the field condition of Options cannot be resolved into a Number. If I change the type of the Options field to Opaque it can be parsed successfully (at least there is not the particular error you described).

One option that comes to mind to resolve this, is to treat an Array field similar to an Opaque field for this matter so that it is not needed to explicitly evaluate the size of the field if the Message variable is present in the size expression.

When setting an Array field where the size cannot be resolved, the set_field_without_size function would be used. Therefore it is needed to ensure that the field is accessible by using the _is_valid_opaque_field method (rename) to enable that, because normally a field without a size would not be accessible and thus could not be set.

@treiher
Copy link
Collaborator Author

treiher commented Mar 19, 2021

Sounds like a reasonable solution to me. As long as there are no major roadblocks to realization, let's do it that way.

@rssen rssen moved this from To do to In progress in RecordFlux 0.5 Mar 19, 2021
@rssen rssen moved this from In progress to Done in RecordFlux 0.5 Mar 19, 2021
RecordFlux 0.5 automation moved this from Done to Merged Mar 22, 2021
@treiher treiher mentioned this issue Aug 4, 2021
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug pyrflx Related to pyrflx package (Legacy Python API)
Projects
No open projects
RecordFlux 0.5
  
Merged
Development

Successfully merging a pull request may close this issue.

2 participants