snstac / pytak

PyTAK is a Python package for rapid TAK integration.
https://pytak.readthedocs.io/en/stable/
Apache License 2.0
156 stars 42 forks source link

xml.etree.ElementTree.ParseError: not well-formed #56

Closed ampledata closed 8 months ago

ampledata commented 9 months ago

Getting the following for TAK_PROTO=1


2023-12-06 15:14:33,887 pytak INFO - Run: <class 'pytak.classes.CLITool'>
2023-12-06 15:14:33,888 pytak INFO - Run: <class 'pytak.classes.RXWorker'>
2023-12-06 15:14:33,889 pytak INFO - Run: <class 'pytak.classes.TXWorker'>
2023-12-06 15:14:33,989 pytak INFO - Complete: <Task finished name='Task-3' coro=<Worker.run() done, defined at /Users/gba/src/SNS/pytak/pytak/classes.py:108> exception=ParseError('not well-formed (invalid token): line 2, column 268')>
Task exception was never retrieved
future: <Task finished name='Task-3' coro=<Worker.run() done, defined at /Users/gba/src/SNS/pytak/pytak/classes.py:108> exception=ParseError('not well-formed (invalid token): line 2, column 268')>
Traceback (most recent call last):
  File "/Users/gba/src/SNS/pytak/pytak/classes.py", line 127, in run
    await self.handle_data(data)
  File "/Users/gba/src/SNS/pytak/pytak/classes.py", line 155, in handle_data
    await self.send_data(data)
  File "/Users/gba/src/SNS/pytak/pytak/classes.py", line 174, in send_data
    data = takproto.xml2proto(data, proto)
  File "/Users/gba/src/SNS/takproto/takproto/functions.py", line 81, in xml2proto
    event = ET.fromstring(xml)
  File "/Users/gba/.pyenv/versions/3.9.4/lib/python3.9/xml/etree/ElementTree.py", line 1347, in XML
    parser.feed(text)
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 2, column 268```
davesauce14 commented 9 months ago

I had this issue too, it has to the with the flow tags implementation, commenting it out resolved the issue:

     flow_tags = ET.Element("_flow-tags_")
    _ft_tag: str = f"{pytak.DEFAULT_HOST_ID}-v{pytak.__version__}"
    flow_tags.set(_ft_tag, pytak.cot_time())

evaluates to the following for me: <_flow-tags_ pytak@Raiden-v6.2.2="2023-12-15T00:57:19.216182Z" />

@ is invalid in xml attribute