Handle lxml exception when parsing Netconf response. #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Due to a mistake on Netconf server side a malformed RPC reply is received at netconf_client
leading to an exception when parsing the response (lxml.etree.fromstring) in the receive loop.
Unfortunately, the traceback (see below, please) is shown in CLI output and the CLI command times out.
With the moved source code line at least the output should no longer appear.
Nevertheless, the command will still run into timeout.
A better approach would be to set the future's exception. But, I don't know what I should pass to the RpcError constructor.
Exception in thread Thread-15 (_recv_loop): Traceback (most recent call last): File "/usr/local/lib/python3.10/threading.py", line 1009, in _bootstrap_inner self.run() File "/usr/local/lib/python3.10/threading.py", line 946, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.10/site-packages/netconf_client/session.py", line 115, in _recv_loop ele = etree.fromstring(msg) File "src/lxml/etree.pyx", line 3237, in lxml.etree.fromstring File "src/lxml/parser.pxi", line 1896, in lxml.etree._parseMemoryDocument File "src/lxml/parser.pxi", line 1784, in lxml.etree._parseDoc File "src/lxml/parser.pxi", line 1141, in lxml.etree._BaseParser._parseDoc File "src/lxml/parser.pxi", line 615, in lxml.etree._ParserContext._handleParseResultDoc File "src/lxml/parser.pxi", line 725, in lxml.etree._handleParseResult File "src/lxml/parser.pxi", line 654, in lxml.etree._raiseParseError File "<string>", line 1 lxml.etree.XMLSyntaxError: PCDATA invalid Char value 22, line 1, column 338