Core: Error handling request after update to 0.57.2

Created on 11 Nov 2017  路  28Comments  路  Source: home-assistant/core

Home Assistant release (hass --version):
0.57.2

Python release (python3 --version):
Python 3.5.3

Description of problem:
I just upgraded HomeAssistant to 0.57.2 according to the Raspberry Pi All-In-One installer docs, and after installing I retrieve a 500 Internal Server Error. It was working perfectly until this last update.

Expected:
A working dashboard :-)

Traceback (if applicable):

2017-11-11 13:50:03 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 278, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 274, in aiohttp._http_parser.HttpParser.feed_data (aiohttp/_http_parser.c:4364)
  File "aiohttp/_http_parser.pyx", line 334, in aiohttp._http_parser.cb_on_url (aiohttp/_http_parser.c:5381)
  File "aiohttp/_http_parser.pyx", line 544, in aiohttp._http_parser._parse_url (aiohttp/_http_parser.c:8777)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/aiohttp/http_writer.py", line 317, in __init__
    path = yarl.quote(path, safe='@:', protected='/', strict=False)
  File "yarl/_quoting.pyx", line 38, in yarl._quoting._quote
TypeError: _quote() got an unexpected keyword argument 'strict'

Additional info:
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 9.1 (stretch)
Release: 9.1
Codename: stretch

All 28 comments

@iMicknl same thing happend to me, tried reverting back to 0.57.1 but that did not work, so tried the dev version and now can connect.

@ludeeus thanks for sharing your experience. I just tried reverting to 0.57.1 also, but that didn't work out. I will try the dev branch for now.

Update: Upgrading to the dev branch fixes my issues also.

Seems the source of this error is the following change in yarl: https://github.com/aio-libs/yarl/issues/123

Yep, reverting yarl to 0.13.0 has fixed it for me.

Had a slightly different error, but reverting to yarl 0.13.0 (pip3 install yarl==0.13.0) also fixed it for me:

--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.4/logging/__init__.py", line 978, in emit
    msg = self.format(record)
  File "/usr/lib/python3.4/logging/__init__.py", line 828, in format
    return fmt.format(record)
  File "/srv/homeassistant/lib/python3.4/site-packages/colorlog/colorlog.py", line 119, in format
    message = super(ColoredFormatter, self).format(record)
  File "/usr/lib/python3.4/logging/__init__.py", line 573, in format
    record.exc_text = self.formatException(record.exc_info)
  File "/usr/lib/python3.4/logging/__init__.py", line 523, in formatException
    traceback.print_exception(ei[0], ei[1], tb, None, sio)
  File "/usr/lib/python3.4/traceback.py", line 169, in print_exception
    for line in _format_exception_iter(etype, value, tb, limit, chain):
  File "/usr/lib/python3.4/traceback.py", line 146, in _format_exception_iter
    for value, tb in values:
  File "/usr/lib/python3.4/traceback.py", line 125, in _iter_chain
    context = exc.__context__
AttributeError: 'NoneType' object has no attribute '__context__'
Call stack:
  File "/srv/homeassistant/bin/hass", line 11, in <module>
    sys.exit(main())
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/__main__.py", line 366, in main
    exit_code = setup_and_run_hass(config_dir, args)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/__main__.py", line 293, in setup_and_run_hass
    return hass.start()
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/core.py", line 158, in start
    self.loop.run_forever()
  File "/usr/lib/python3.4/asyncio/base_events.py", line 244, in run_forever
    self._run_once()
  File "/usr/lib/python3.4/asyncio/base_events.py", line 1081, in _run_once
    handle._run()
  File "/usr/lib/python3.4/asyncio/events.py", line 120, in _run
    self._callback(*self._args)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/web_protocol.py", line 557, in handle_parse_error
    resp = self.handle_error(request, status, exc, message)
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/web_protocol.py", line 522, in handle_error
    self.log_exception("Error handling request", exc_info=exc)
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/web_protocol.py", line 362, in log_exception
    self.logger.exception(*args, **kw)
Message: 'Error handling request'
Arguments: ()

+1 for me.

And +1 for reverting to yarl 0.13.0 solved the problem. I am using the virtual environment install and executing the pip3 install yarl==0.13.0 within the virtual environment solved the issue for me after reboot.

I'm not sure why that error appears in aiohttp for you, but the yarl change breaking Google TTS should be fixed with https://github.com/home-assistant/home-assistant/pull/10527 . Could you check if applying that PR fixes the problem for you?

Same error for me...
I reinstalled it today...
I tried "pip3 install yarl==0.13.0" but unfortunately it doesn't fix anything...

I was able to fix it by adding
yarl==0.13.0
to package_constraints.txt inside the homeassistant package as a temporary fix

Had the same problem. fixed it with yarl==0.13.0

I'm preparing hotfix 0.57.3 with this fix

ETA for fix?

I did a completely new installation and faced the above error.
I tried "pip3 install yarl==0.13.0" but unfortunately it doesn't fix anything.

Right now tested 0.57.3 on Raspian Stretch.
When calling the Dashboard I get:

homeassistant.service - Home Assistant
   Loaded: loaded (/lib/systemd/system/homeassistant.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2017-11-11 22:37:55 CET; 7min ago
 Main PID: 627 (hass)
   CGroup: /system.slice/homeassistant.service
           鈹斺攢627 /usr/bin/python3 /usr/local/bin/hass

Nov 11 22:45:01 base hass[627]: Traceback (most recent call last):
Nov 11 22:45:01 base hass[627]:   File "/home/pi/.homeassistant/deps/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 278, in data_received
Nov 11 22:45:01 base hass[627]:     messages, upgraded, tail = self._request_parser.feed_data(data)
Nov 11 22:45:01 base hass[627]:   File "aiohttp/_http_parser.pyx", line 274, in aiohttp._http_parser.HttpParser.feed_data (aiohttp/_http_parser.c:4364)
Nov 11 22:45:01 base hass[627]:   File "aiohttp/_http_parser.pyx", line 334, in aiohttp._http_parser.cb_on_url (aiohttp/_http_parser.c:5381)
Nov 11 22:45:01 base hass[627]:   File "aiohttp/_http_parser.pyx", line 544, in aiohttp._http_parser._parse_url (aiohttp/_http_parser.c:8777)
Nov 11 22:45:01 base hass[627]:   File "/home/pi/.homeassistant/deps/lib/python3.5/site-packages/aiohttp/http_writer.py", line 317, in __init__
Nov 11 22:45:01 base hass[627]:     path = yarl.quote(path, safe='@:', protected='/', strict=False)
Nov 11 22:45:01 base hass[627]:   File "yarl/_quoting.pyx", line 38, in yarl._quoting._quote
Nov 11 22:45:01 base hass[627]: TypeError: _quote() got an unexpected keyword argument 'strict'

@RaphaelVogel I think you have this error because yarl is still on version 0.14.0 in your environment. Are you running hass in a venv?
What version is yarl when you do pip3 list?

This problem with (likely) missing versioning on yarl seems to break new installs of Hassbian 1.31 (latest) as well.

@ebisso I have tried both versions of yarl (0.13.0 and 0.14.0). Both do not work, I get the same error if I call http://<ip of host>:8123. As far as I understand documentation this is the default port?

pip3 list
...
yarl (0.13.0)

I'm a first time user of HASS. , so I guess I will try with virtualenv now.

After installing into virtualenv everything works with 0.57.3
Thx

I'm experiencing the same issue ... Tried with virtualenv too but failed miserably ...

Home Assistant release (hass --version):
0.57.3

Python release (python3 --version):
Python 3.5.2

Component - versions tested:
aiohttp - (2.3.2) / (2.2.5)
yarl - (0.13.0) / (0.14.0)

ERROR:aiohttp.server:Error handling request
Traceback (most recent call last):
  File "/home/mtv/.homeassistant/deps/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 278, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 274, in aiohttp._http_parser.HttpParser.feed_data (aiohttp/_http_parser.c:4364)
  File "aiohttp/_http_parser.pyx", line 334, in aiohttp._http_parser.cb_on_url (aiohttp/_http_parser.c:5381)
  File "aiohttp/_http_parser.pyx", line 544, in aiohttp._http_parser._parse_url (aiohttp/_http_parser.c:8777)
  File "/home/mtv/.homeassistant/deps/lib/python3.5/site-packages/aiohttp/http_writer.py", line 317, in __init__
    path = yarl.quote(path, safe='@:', protected='/', strict=False)
  File "yarl/_quoting.pyx", line 38, in yarl._quoting._quote
TypeError: _quote() got an unexpected keyword argument 'strict'

Doesn't work for me either. I tried uninstalling and reinstalling homeassistant python package but I still get the exact error message @marco-vaz posted.

My current package versions:

aiohttp==2.2.5
astral==1.4
async-timeout==2.0.0
certifi==2017.11.5
chardet==3.0.4
construct==2.8.16
homeassistant==0.57.3
idna==2.6
Jinja2==2.10
MarkupSafe==1.0
multidict==3.3.2
pytz==2017.3
PyYAML==3.12
raspyrfm-client==1.2.1
requests==2.18.4
sqlite3==0.0.0
sunix-ledstrip-controller-client==1.1.1
typing==3.6.2
urllib3==1.22
voluptuous==0.10.5
yarl==0.13.0

I am running in a docker environment and i tried pip install yarl==0.13.0 and pip install --upgrade yarl==0.13.0 in the docker image but the problem persist. Any ideas what do try ?

@markusressel Your aiohttp is too old.
@marco-vaz I assume it's the same for you.

@tinloaf i just upgraded aiohttp to 2.3.2 which then installed yarl (0.14.0) and then i downgraded to yarl to 0.13.0 and i still can't get it to work. My Python is 3.6.3 Any ideas ?

Maybe the problem is different now :

2017-11-13 10:00:32 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 416, in start
    resp = yield from self._request_handler(request)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web.py", line 317, in _handle
    for m, new_style in app._middlewares:
TypeError: 'function' object is not iterable
2017-11-13 10:00:36 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 416, in start
    resp = yield from self._request_handler(request)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web.py", line 317, in _handle
    for m, new_style in app._middlewares:
TypeError: 'function' object is not iterable
2017-11-13 10:00:37 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 416, in start
    resp = yield from self._request_handler(request)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web.py", line 317, in _handle
    for m, new_style in app._middlewares:
TypeError: 'function' object is not iterable

Sorry, no. Apart from that home assistant currently actually wants aiohttp 2.3.1 (and not 2.3.2), but as far as I can see from the code, that should not make a difference. Still doesn't hurt to try, I think.

So i just solved my problem using the dev in docker instead of latest which is 0.57.3

Latest dev docker should have aiohttp 2.3.2 and yarl 0.14.0, correct?

Yes it does and it works

Can s.o. with a working 0.57.3 just post a pip freeze? would make things much easier to compare...
I hope a 0.57.4 will be released to adress this as quickly as possible.

EDIT
I fixed it by using python 3.6 instead of 3.5 and reinstalling everything from scratch.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ariel-madril picture ariel-madril  路  451Comments

Gio76 picture Gio76  路  223Comments

WilldabeastHA picture WilldabeastHA  路  203Comments

nodkan picture nodkan  路  161Comments

aguilaair picture aguilaair  路  162Comments