nasa/fprime-tools

Enum Schematron error

Closed this issue · 1 comments

F´ Version 2.0
Affected Component all

Problem Description

The schematron rule checker for enums crashes if no enum values are specified.

/fprime/Autocoders/Python/schema/default/enum_value_schematron.rng

How to Reproduce

  1. Create an enum without values
  2. Compile

Expected Behavior

I would expect:

  1. It would give me an error telling me about a missing value field.

Problem is that the rule has the following comment:

Either all enum items should have a value or none should

or, 2) based on the comment, it would allow the enum with no values.

The schematron error produces an exception that should be handled cleanly:

WARNING: XML file XXXXEnumAi.xml is not valid according to schematron x/fprime/Autocoders/Python/src/fprime_ac/parsers/../../../../../Autocoders/Python/schema/default/enum_value_schematron.rng.
Parsing Enum XXXX
'value'
Traceback (most recent call last):
  File "x/fprime/Autocoders/Python/bin/codegen.py", line 1338, in <module>
    main()
  File "x/fprime/Autocoders/Python/bin/codegen.py", line 1294, in main
    if EnumGenerator.generate_enum(xml_filename):
  File "x/fprime/Autocoders/Python/src/fprime_ac/utils/EnumGenerator.py", line 64, in generate_enum
    enum_xml = XmlEnumParser.XmlEnumParser(xml_file)
  File "x/fprime/Autocoders/Python/src/fprime_ac/parsers/XmlEnumParser.py", line 115, in __init__
    self.__items.append((item["name"], item["value"], item["comment"]))
  File "src/lxml/etree.pyx", line 2479, in lxml.etree._Attrib.__getitem__
KeyError: 'value'

(Directory names were edited out)

@timcanham I think this is an F´ core issue we should track. The Autocoder still lives in F´.