mozilla-services / crashstats-tools

Command line tools and library for interacting with Crash Stats (https://crash-stats.mozilla.org/)
Mozilla Public License 2.0
9 stars 0 forks source link

libcrashstats obscures errors and makes it hard to debug them #139

Closed willkg closed 2 months ago

willkg commented 3 months ago
Traceback (most recent call last):
  File "/home/willkg/tmp/supersearch_match_test/.venv/lib/python3.10/site-packages/requests/models.py", line 974, in json
    return complexjson.loads(self.text, **kwargs)
  File "/home/willkg/.pyenv/versions/3.10.14/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/home/willkg/.pyenv/versions/3.10.14/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/willkg/.pyenv/versions/3.10.14/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/willkg/tmp/supersearch_match_test/do_supersearch.py", line 111, in <module>
    if __name__ == "__main__":
  File "/home/willkg/tmp/supersearch_match_test/.venv/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/willkg/tmp/supersearch_match_test/.venv/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/willkg/tmp/supersearch_match_test/.venv/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/willkg/tmp/supersearch_match_test/.venv/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/willkg/tmp/supersearch_match_test/.venv/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/willkg/tmp/supersearch_match_test/do_supersearch.py", line 94, in main
    click.echo(f"WORKING ON {values!r}")
  File "/home/willkg/tmp/supersearch_match_test/.venv/lib/python3.10/site-packages/crashstats_tools/libcrashstats.py", line 135, in supersearch
    resp = http_get(url=url, params=params, api_token=api_token)
  File "/home/willkg/tmp/supersearch_match_test/.venv/lib/python3.10/site-packages/crashstats_tools/utils.py", line 216, in http_get
    raise BadRequest(resp.json().get("error", "No error provided"))
  File "/home/willkg/tmp/supersearch_match_test/.venv/lib/python3.10/site-packages/requests/models.py", line 978, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

In that, there's some error with the returned JSON, but there's no way to know what the HTTP response status code was or what was in the response data.

We should improve supersearch such that it's easier to debug these situations.