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

AttributeError Response content isn't text #1

Open
tonal opened this issue Jul 16, 2020 · 0 comments
Open

AttributeError Response content isn't text #1

tonal opened this issue Jul 16, 2020 · 0 comments

Comments

@tonal
Copy link

tonal commented Jul 16, 2020

AttributeError: Response content isn't text
  File "scrapy/utils/signal.py", line 32, in send_catch_log
    response = robustApply(receiver, signal=signal, sender=sender, *arguments, **named)
  File "pydispatch/robustapply.py", line 55, in robustApply
    return receiver(*arguments, **named)
  File "sentry_scrapy/extension.py", line 39, in spider_error
    scope.set_extra('response', response_to_dict(response))
  File "sentry_scrapy/utils.py", line 12, in response_to_dict
    'body': response.text,
  File "scrapy/http/response/__init__.py", line 108, in text
    raise AttributeError("Response content isn't text")

My manky path:

def _manky_path_sentry_scrapy_utils():
  from scrapy.http import TextResponse
  def response_to_dict(response):
    """
    Convert a `scrapy.http.Response` to a dictionnary.
    """
    fields = {
      'status': response.status,
      'url': response.url,
      'headers': response.headers.to_unicode_dict(),}
    if isinstance(response, TextResponse):
      fields.update(body=response.text)
    return fields

  from sentry_scrapy import utils
  response_to_dict.__module__ = utils
  utils.response_to_dict = response_to_dict
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

No branches or pull requests

1 participant