Skip to content

SAXParseException #196

@charles-cooper

Description

@charles-cooper

In some reports, the following exception is being thrown:

  File "/usr/local/lib/python3.5/dist-packages/googleads/util.py", line 100, in PatchedHttpTransportSend
    fp = self.u2open(u2request)
  File "/usr/local/lib/python3.5/dist-packages/suds/transport/http.py", line 132, in u2open
    return url.open(u2request, timeout=tm)
  File "/usr/lib/python3.5/urllib/request.py", line 472, in open
    response = meth(req, response)
  File "/usr/lib/python3.5/urllib/request.py", line 582, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.5/urllib/request.py", line 510, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 590, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: Internal Server Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/suds/client.py", line 613, in send
    reply = self.options.transport.send(request)
  File "/usr/local/lib/python3.5/dist-packages/googleads/util.py", line 105, in PatchedHttpTransportSend
    raise suds.transport.TransportError(e.msg, e.code, e.fp)
suds.transport.TransportError: Internal Server Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/xml/sax/expatreader.py", line 210, in feed
    self._parser.Parse(data, isFinal)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./dfp.py", line 86, in <module>
    job_id = report_downloader.WaitForReport(query)
  File "/usr/local/lib/python3.5/dist-packages/googleads/dfp.py", line 433, in WaitForReport
    report_job_id = service.runReportJob(report_job)['id']
  File "/usr/local/lib/python3.5/dist-packages/googleads/common.py", line 720, in MakeSoapRequest
    *[_PackForSuds(arg, self.suds_client.factory) for arg in args])
  File "/usr/local/lib/python3.5/dist-packages/suds/client.py", line 521, in __call__
    return client.invoke(args, kwargs)
  File "/usr/local/lib/python3.5/dist-packages/suds/client.py", line 581, in invoke
    result = self.send(soapenv)
  File "/usr/local/lib/python3.5/dist-packages/suds/client.py", line 619, in send
    description=tostr(e), original_soapenv=original_soapenv)
  File "/usr/local/lib/python3.5/dist-packages/suds/client.py", line 661, in process_reply
    replyroot = _parse(reply)
  File "/usr/local/lib/python3.5/dist-packages/suds/client.py", line 833, in _parse
    return Parser().parse(string=string)
  File "/usr/local/lib/python3.5/dist-packages/suds/sax/parser.py", line 133, in parse
    sax.parse(source)
  File "/usr/lib/python3.5/xml/sax/expatreader.py", line 110, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "/usr/lib/python3.5/xml/sax/xmlreader.py", line 125, in parse
    self.feed(buffer)
  File "/usr/lib/python3.5/xml/sax/expatreader.py", line 214, in feed
    self._err_handler.fatalError(exc)
  File "/usr/lib/python3.5/xml/sax/handler.py", line 38, in fatalError
    raise exception
xml.sax._exceptions.SAXParseException: <unknown>:1:0: not well-formed (invalid token)

This is pretty strange. I modified my local version of suds/client.py to print out the response and I got a bytestring beginning with the sequence \x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x00.

The specific report I tried to generate was

dimensions = [ 'ORDER_ID', 'ORDER_NAME', 'DATE', 'HOUR' ]
 
columns = \
    [ 'AD_SERVER_IMPRESSIONS'
    , 'AD_SERVER_CLICKS'
    , 'AD_SERVER_CPM_AND_CPC_REVENUE'
    , 'AD_SERVER_CPA_REVENUE' # commenting this out works
    , 'AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM'
    # , 'AD_SERVER_WITH_CPD_AVERAGE_ECPM'
    , 'AD_SERVER_CTR'
     ]

    def mkDateDict (dt) :
        ret = { 'year': dt.year
              , 'month': dt.month
              , 'day': dt.day
              }
        return ret

    query = {
        'reportQuery': {
            'dimensions': dimensions,
            # 'dimensionAttributes': [],
            'columns': columns,
            'dateRangeType': 'CUSTOM_DATE',
            'startDate': mkDateDict(start_date),
            'endDate': mkDateDict(end_date)
            }
        }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions