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

Handle lxml exception when parsing Netconf response. #15

Merged
merged 2 commits into from
Dec 15, 2021

Conversation

skolbel
Copy link
Contributor

@skolbel skolbel commented Dec 15, 2021

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

Copy link
Member

@JennToo JennToo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! The goal of this NETCONF client was to enable testing against buggy NETCONF servers, so this is definitely something we want to catch.

I'll go work on fixing the CI, I think it'll just need an update.

@JennToo JennToo merged commit 9f2430b into ADTRAN:main Dec 15, 2021
@JennToo
Copy link
Member

JennToo commented Dec 15, 2021

This was published with version 2.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants