nasa/fprime-tools

String-parameter default generates incorrect XML

dmitri-mcguckin opened this issue · 3 comments

F´ Version 3.1.1
Affected Component Custom F-Prime Component

Problem Description

When establishing a parameter on my custom component of type string, I do it like so:

param TN_HOST : string default "localhost"

Then upon running fprime-util build

The tool crashes with the following error:

attributes construct error, line 143, column 114 (PDUComponentAi.xml, line 143)
Traceback (most recent call last):
  File "./fprime/Autocoders/Python/bin/codegen.py", line 1334, in <module>
    main()
  File "./fprime/Autocoders/Python/bin/codegen.py", line 1255, in main
    xml_type = XmlParser.XmlParser(xml_filename)()
  File "./fprime/Autocoders/Python/src/fprime_ac/parsers/XmlParser.py", line 45, in __init__
    element_tree = etree.parse(fd)
  File "src/lxml/etree.pyx", line 3538, in lxml.etree.parse
  File "src/lxml/parser.pxi", line 1897, in lxml.etree._parseDocument
  File "src/lxml/parser.pxi", line 1917, in lxml.etree._parseFilelikeDocument
  File "src/lxml/parser.pxi", line 1811, in lxml.etree._parseDocFromFilelike
  File "src/lxml/parser.pxi", line 1201, in lxml.etree._BaseParser._parseDocFromFilelike
  File "src/lxml/parser.pxi", line 615, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 725, in lxml.etree._handleParseResult
make[3]: *** [CGSClient/PDU/CMakeFiles/CGSClient_PDU.dir/build.make:75: CGSClient/PDU/PDUComponentAc.hpp] Error 255
make[2]: *** [CMakeFiles/Makefile2:7581: CGSClient/PDU/CMakeFiles/CGSClient_PDU.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:7589: CGSClient/PDU/CMakeFiles/CGSClient_PDU.dir/rule] Error 2
make: *** [Makefile:2249: CGSClient_PDU] Error 2
  File "src/lxml/parser.pxi", line 654, in lxml.etree._raiseParseError
  File "./CGSClient/build-fprime-automatic-native/CGSClient/PDU/PDUComponentAi.xml", line 143
lxml.etree.XMLSyntaxError: attributes construct error, line 143, column 114

When manually inspecting ./CGSClient/build-fprime-automatic-native/CGSClient/PDU/PDUComponentAi.xml line 143, I can clearly see that any quotes surround a string in an *.fpp file are included as part of a string-literal in the generated XML.

This is the line in question:

<parameters>
    <parameter id="0x0" set_opcode="0x2" save_opcode="0x3" name="TN_HOST" data_type="string" size="80" default=""localhost""/>
</parameters>

Specifically drawing attention to

default=""localhost""

Which if I manually adjust to:

default="localhost"

It all works like a charm.

How to Reproduce

  1. Set a string-type default for a parameter such as: param TN_HOST : string default "localhost"
  2. Run fprime-util build
  3. Manually inspect corresponding *ComponentAi.xml file

Expected Behavior

I expect the generated XML to only contain one-pair of strings surrounding the default field instead of two.

This issue is documented here: nasa/fprime#1733. We have pushed a fix to the devel branch.

Sounds great. Is there any ETA when we can expect the next release with the fix?

Bug fixed on the FPP side. Closing.