lczub / TestLink-API-Python-client

A Python client to use the TestLink API
105 stars 63 forks source link

addTestCaseToTestPlan failed with "xml.parsers.expat.ExpatError: junk after document element: line 1, column 91" #60

Closed kennethwork99 closed 8 years ago

kennethwork99 commented 9 years ago

What is the expected behavior with adding existing test cases to test plan? Should it failed with "testlink.testlinkerrors.TLResponseError" instead of xml error? Initially I called addTestCaseToTestPlan and it worked fine. Later on user added new test cases. l was curious what would happen if calling addTestCaseToTestPlan again with existing tests and new tests and found the xml.parsers.expat.ExpatError.

python pztestlink.py --addTestCaseToTestPlan --testprojectname CloudController --testplanname 7.0.0.0 --testsuitename 'Regression - Group' Traceback (most recent call last): File "pztestlink.py", line 1176, in tl.AddTestCaseToTestPlan() File "pztestlink.py", line 419, in AddTestCaseToTestPlan testcase['external_id'], version=1) File "pztestlink.py", line 389, in addTestCaseToTestPlan devKey=self.devkey) File "/home/kwong/venv/py2.7/lib/python2.7/site-packages/testlink/testlinkdecorators.py", line 105, in wrapperAddDevKey return methodAPI(self, _argsPositional, _argsOptional) File "/home/kwong/venv/py2.7/lib/python2.7/site-packages/testlink/testlinkdecorators.py", line 93, in wrapperWithArgs _argsPositional, _argsOptional) File "/home/kwong/venv/py2.7/lib/python2.7/site-packages/testlink/testlinkapigeneric.py", line 1297, in callServerWithPosArgs response = self._callServer(methodNameAPI, argsOptional) File "/home/kwong/venv/py2.7/lib/python2.7/site-packages/testlink/testlinkapigeneric.py", line 1356, in _callServer response = getattr(self.server.tl, methodNameAPI)(argsAPI) File "/home/kwong/.localpython/lib/python2.7/xmlrpclib.py", line 1224, in call return self.send(self.name, args) File "/home/kwong/.localpython/lib/python2.7/xmlrpclib.py", line 1578, in request verbose=self.verbose File "/home/kwong/.localpython/lib/python2.7/xmlrpclib.py", line 1264, in request return self.single_request(host, handler, request_body, verbose) File "/home/kwong/.localpython/lib/python2.7/xmlrpclib.py", line 1297, in single_request return self.parse_response(response) File "/home/kwong/.localpython/lib/python2.7/xmlrpclib.py", line 1467, in parse_response p.feed(data) File "/home/kwong/.localpython/lib/python2.7/xmlrpclib.py", line 557, in feed self._parser.Parse(data, 0) xml.parsers.expat.ExpatError: junk after document element: line 1, column 91

lczub commented 9 years ago

Hello Kenneth,

currently, invalid XML responses from TL are not catch as an TLResponseError.
Invalid XML responses happens when an internal TL failure occurs.

In your case, following invalid xml content is returned it seams, that TL does not catch some db errors for your invalid request

<pre> ============================================================================== </pre>
<pre> DB Access Error - debug_print_backtrace() OUTPUT START </pre>
<pre> ATTENTION: Enabling more debug info will produce path disclosure weakness (CWE-200) </pre>
<pre>            Having this additional Information could be useful for reporting </pre><pre>            issue to development TEAM. </pre>
<pre> ============================================================================== </pre>
<pre> ============================================================================== </pre>
<?xml version="1.0"?>\n<methodResponse>\n  <params>\n    <param>\n      <value>\n        <struct>\n  
<member><name>feature_id</name><value><string>1347</string></value></member>\n 
<member><name>operation</name><value><string>addTestCaseToTestPlan</string></value></member>\n  
<member><name>status</name><value><boolean>1</boolean></value></member>\n  
<member><name>message</name><value><string></string></value></member>\n
</struct>\n      </value>\n    </param>'
lczub commented 8 years ago

Currently the python client will not catch such TL internal server errors. Please report such internal server errors to TL ( http://mantis.testlink.org/ ) , so that these problems are fixed inside the server.

regards Luiko