<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Splunklib (python)/API issues after update to 7.2.0: &amp;quot;ParseError: mismatched tag: line 10625, column 2&amp;quot;. in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Splunklib-python-API-issues-after-update-to-7-2-0-quot/m-p/455715#M8294</link>
    <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;I have been running some scripts using splunklib for the past year or so without any issues. I recently updated our indexers to 7.2.0 and am now receiving the occasional errors. The below issues happens every once in a while in about 5 scripts, and every time in another. &lt;/P&gt;

&lt;P&gt;Here is a the traceback:&lt;/P&gt;

&lt;P&gt;Error on REDACTED:&lt;BR /&gt;
Traceback (most recent call last):&lt;BR /&gt;
  File "REDACTED.py", line 152, in &lt;BR /&gt;
    message += REDACTED.REDACTED(REDACTED)&lt;BR /&gt;
  File "/REDACTED/REDACTED/REDACTED/REDACTED/REDACTED/REDACTED.py", line 93, in REDACTED&lt;BR /&gt;
    REDACTED = REDACTED(REDACTED,REDACTED)&lt;BR /&gt;
  File "/REDACTED/REDACTED/REDACTED/REDACTED/REDACTED/REDACTED.py", line 43, in REDACTED&lt;BR /&gt;
    for result in results:&lt;BR /&gt;
  File "/usr/local/lib/python2.7/dist-packages/splunklib/results.py", line 205, in next&lt;BR /&gt;
    return self._gen.next()&lt;BR /&gt;
  File "/usr/local/lib/python2.7/dist-packages/splunklib/results.py", line 212, in _parse_results&lt;BR /&gt;
    for event, elem in et.iterparse(stream, events=('start', 'end')):&lt;BR /&gt;
  File "", line 91, in next&lt;BR /&gt;
ParseError: mismatched tag: line 10625, column 2&lt;/P&gt;

&lt;P&gt;I am not sure what the issue is here. To debug a bit easier, I took the exact code that made searches and put it in its own file. After running it the first time, it iterated over about half of the results in the search and failed with the above error. The remaining times it has worked fine. This same issue happens in several scripts that seem to have no correlation with each other.&lt;/P&gt;

&lt;P&gt;To make it more clear, here is example source:&lt;/P&gt;

&lt;P&gt;import splunklib.results as results&lt;BR /&gt;
import splunklib.client as client&lt;/P&gt;

&lt;P&gt;def execute_search(search_string, service):&lt;BR /&gt;
    kwargs_export = {"earliest_time": "-7d", "latest_time": "now", "search_mode": "normal"}&lt;BR /&gt;
    exportsearch_results = service.jobs.export(searchString, **kwargs_export)&lt;BR /&gt;
    return results.ResultsReader(exportsearch_results)&lt;/P&gt;

&lt;P&gt;token = client.connect( host='splunk_server', port= 8089, username='user', password='pass')&lt;BR /&gt;
results = execute_search("search index=example", token)&lt;/P&gt;

&lt;H4&gt;Here is where it fails during iteration:&lt;/H4&gt;

&lt;P&gt;for result in results:&lt;BR /&gt;
    print result&lt;/P&gt;

&lt;P&gt;I would appreciate any insight anyone can provide. &lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 21:50:32 GMT</pubDate>
    <dc:creator>dan_ritter</dc:creator>
    <dc:date>2020-09-29T21:50:32Z</dc:date>
    <item>
      <title>Splunklib (python)/API issues after update to 7.2.0: "ParseError: mismatched tag: line 10625, column 2".</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunklib-python-API-issues-after-update-to-7-2-0-quot/m-p/455715#M8294</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;I have been running some scripts using splunklib for the past year or so without any issues. I recently updated our indexers to 7.2.0 and am now receiving the occasional errors. The below issues happens every once in a while in about 5 scripts, and every time in another. &lt;/P&gt;

&lt;P&gt;Here is a the traceback:&lt;/P&gt;

&lt;P&gt;Error on REDACTED:&lt;BR /&gt;
Traceback (most recent call last):&lt;BR /&gt;
  File "REDACTED.py", line 152, in &lt;BR /&gt;
    message += REDACTED.REDACTED(REDACTED)&lt;BR /&gt;
  File "/REDACTED/REDACTED/REDACTED/REDACTED/REDACTED/REDACTED.py", line 93, in REDACTED&lt;BR /&gt;
    REDACTED = REDACTED(REDACTED,REDACTED)&lt;BR /&gt;
  File "/REDACTED/REDACTED/REDACTED/REDACTED/REDACTED/REDACTED.py", line 43, in REDACTED&lt;BR /&gt;
    for result in results:&lt;BR /&gt;
  File "/usr/local/lib/python2.7/dist-packages/splunklib/results.py", line 205, in next&lt;BR /&gt;
    return self._gen.next()&lt;BR /&gt;
  File "/usr/local/lib/python2.7/dist-packages/splunklib/results.py", line 212, in _parse_results&lt;BR /&gt;
    for event, elem in et.iterparse(stream, events=('start', 'end')):&lt;BR /&gt;
  File "", line 91, in next&lt;BR /&gt;
ParseError: mismatched tag: line 10625, column 2&lt;/P&gt;

&lt;P&gt;I am not sure what the issue is here. To debug a bit easier, I took the exact code that made searches and put it in its own file. After running it the first time, it iterated over about half of the results in the search and failed with the above error. The remaining times it has worked fine. This same issue happens in several scripts that seem to have no correlation with each other.&lt;/P&gt;

&lt;P&gt;To make it more clear, here is example source:&lt;/P&gt;

&lt;P&gt;import splunklib.results as results&lt;BR /&gt;
import splunklib.client as client&lt;/P&gt;

&lt;P&gt;def execute_search(search_string, service):&lt;BR /&gt;
    kwargs_export = {"earliest_time": "-7d", "latest_time": "now", "search_mode": "normal"}&lt;BR /&gt;
    exportsearch_results = service.jobs.export(searchString, **kwargs_export)&lt;BR /&gt;
    return results.ResultsReader(exportsearch_results)&lt;/P&gt;

&lt;P&gt;token = client.connect( host='splunk_server', port= 8089, username='user', password='pass')&lt;BR /&gt;
results = execute_search("search index=example", token)&lt;/P&gt;

&lt;H4&gt;Here is where it fails during iteration:&lt;/H4&gt;

&lt;P&gt;for result in results:&lt;BR /&gt;
    print result&lt;/P&gt;

&lt;P&gt;I would appreciate any insight anyone can provide. &lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:50:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunklib-python-API-issues-after-update-to-7-2-0-quot/m-p/455715#M8294</guid>
      <dc:creator>dan_ritter</dc:creator>
      <dc:date>2020-09-29T21:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: splunklib (python)/api issues after update to 7.2.0: "ParseError: mismatched tag: line 10625, column 2"</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunklib-python-API-issues-after-update-to-7-2-0-quot/m-p/455716#M8295</link>
      <description>&lt;P&gt;i) Try to work out what error it hits, use online xml validator.&lt;/P&gt;

&lt;P&gt;ii) If it's not something you can't fix due to the mal-formatted xml then try to use csv format in the request.. for example in kwargs_export add "output_mode":"csv" .&lt;/P&gt;

&lt;P&gt;kwargs_export = {"earliest_time": "-7d", "latest_time": "now", "search_mode": "normal", "output_mode": "csv" }&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:07:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunklib-python-API-issues-after-update-to-7-2-0-quot/m-p/455716#M8295</guid>
      <dc:creator>sylim_splunk</dc:creator>
      <dc:date>2020-09-30T02:07:45Z</dc:date>
    </item>
  </channel>
</rss>

