Error Preventing Restart - "argument of type ‘NoneType’ is not iterable"

I am receiving an error when I attempt to reboot the system. It says “argument of type ‘NoneType’ is not iterable”.

Since the log stopped at the Helper section, I attempted to just delete all my helpers and that did not correct the problem.

I also restored a couple of backups and the error is still there, though Home Assistant has been able to reboot just fine with the error, unless I try to use the UI to reboot. So ideally fixing the error is the best solution.

> Logger: homeassistant.components.websocket_api.http.connection
Source: helpers/config_validation.py:810
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 5:28:52 PM (2 occurrences)
Last logged: 5:30:33 PM
[140263567565888] argument of type 'NoneType' is not iterable
[140262893487104] argument of type 'NoneType' is not iterable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1787, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1824, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/components/hassio/__init__.py", line 515, in async_handle_core_service
    errors = await conf_util.async_check_ha_config_file(hass)
  File "/usr/src/homeassistant/homeassistant/config.py", line 982, in async_check_ha_config_file
    res = await check_config.async_check_ha_config_file(hass)
  File "/usr/src/homeassistant/homeassistant/helpers/check_config.py", line 233, in async_check_ha_config_file
    p_validated = platform_schema(p_validated)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 232, in __call__
    return self._exec((Schema(val) for val in self.validators), v)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 351, in _exec
    v = func(v)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
    return schema(data)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 387, in validate_mapping
    cval = cvalue(key_path, value)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
    return schema(data)
  File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 543, in verify
    return cast(dict, schema(value))
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 387, in validate_mapping
    cval = cvalue(key_path, value)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 229, in _run
    return self._exec(self._compiled, value, path)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 353, in _exec
    v = func(path, v)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
    return schema(data)
  File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 810, in validator
    if key in config:
TypeError: argument of type 'NoneType' is not iterable

Which HA version are you running? Anything in the logbook around this time?

I’m using version 2023.2.5 and can’t seem to find anything in logbook. At this point I have no idea how far back the problem goes because apparently the system DOES come back if restarted in any other way. I haven’t tried forcing it to restart but I’m pretty sure it’s rebooted since the error surfaced.

Is there a way to see what’s stopping the config check with more detail than what I posted?

Alas, I have no idea how you could find more information. It,s just an assumption, but it sounds to me like an error in automation/script.

So technically if I open up each automation and then try to save it, if there’s a problem it should tell me and not save? Since I’m pretty sure HA validates everything when it tries to save.

Not mandatory. For example, this is obviously wrong


service: light.turn_off
data: 
  brightness: 10
target:
  entity_id: light.couch_licht

but will be saved and the UI editor doesn’t grumble at all.

True - but would that prevent HA from restarting during a config check? Do you know if disabled automations are checked? I’d rather not delete them all, but I could go through and disable them all.

No, HA restarts without any problems. Did you change anything in configuration.yaml?

Not recently. And nothing seems to be “broken” - I just get the error when I try to check/restart.

I just cleared the Automations.yaml, reloaded automations, and then ran the system check and got the same error. Very strange. I don’t know how to do the same for Helpers, since they aren’t in a separate YAML file that I can see.

Did anyone ever get to the bottom of this, I am seeing a similar issue, log as follows:

Logger: homeassistant.components.websocket_api.http.connection
Source: helpers/config_validation.py:828
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 6:25:03 PM (4 occurrences)
Last logged: 6:36:03 PM

[1548932072] argument of type ‘NoneType’ is not iterable
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py”, line 199, in handle_call_service
await hass.services.async_call(
File “/usr/src/homeassistant/homeassistant/core.py”, line 1808, in async_call
task.result()
File “/usr/src/homeassistant/homeassistant/core.py”, line 1845, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 762, in admin_handler
await result
File “/usr/src/homeassistant/homeassistant/components/homeassistant/init.py”, line 297, in async_handle_reload_all
if errors := await conf_util.async_check_ha_config_file(hass):
File “/usr/src/homeassistant/homeassistant/config.py”, line 982, in async_check_ha_config_file
res = await check_config.async_check_ha_config_file(hass)
File “/usr/src/homeassistant/homeassistant/helpers/check_config.py”, line 234, in async_check_ha_config_file
p_validated = platform_schema(p_validated)
File “/usr/local/lib/python3.10/site-packages/voluptuous/validators.py”, line 232, in call
return self._exec((Schema(val) for val in self.validators), v)
File “/usr/local/lib/python3.10/site-packages/voluptuous/validators.py”, line 351, in _exec
v = func(v)
File “/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py”, line 272, in call
return self._compiled([], data)
File “/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py”, line 818, in validate_callable
return schema(data)
File “/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py”, line 272, in call
return self._compiled([], data)
File “/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py”, line 595, in validate_dict
return base_validate(path, iteritems(data), out)
File “/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py”, line 387, in validate_mapping
cval = cvalue(key_path, value)
File “/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py”, line 818, in validate_callable
return schema(data)
File “/usr/src/homeassistant/homeassistant/helpers/config_validation.py”, line 545, in verify
return cast(dict, schema(value))
File “/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py”, line 272, in call
return self._compiled([], data)
File “/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py”, line 595, in validate_dict
return base_validate(path, iteritems(data), out)
File “/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py”, line 387, in validate_mapping
cval = cvalue(key_path, value)
File “/usr/local/lib/python3.10/site-packages/voluptuous/validators.py”, line 229, in _run
return self._exec(self._compiled, value, path)
File “/usr/local/lib/python3.10/site-packages/voluptuous/validators.py”, line 353, in _exec
v = func(path, v)
File “/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py”, line 818, in validate_callable
return schema(data)
File “/usr/src/homeassistant/homeassistant/helpers/config_validation.py”, line 828, in validator
if key in config:
TypeError: argument of type ‘NoneType’ is not iterable

System is working fine, and no obvious errors, but I have added some helpers recently.

OK, found an indentation error in one of the new template / sensor additions. Why are python/YAML error messages so bloody unhelpful, what’s wrong with ‘you are missing an indent’. 8>.

2 Likes

Is there any way to find this without combing through every YAML file separately looking for an errant indentation? That’s going to take forever. Can I copy and paste it someplace online that’ll validate it?

Not that I know of. What have you changed since it last worked.??

I actually don’t know. Because the system will reboot when I update the actual HA software so I didn’t notice it was a problem for a while.

Found it the slow-going way. I commented out each YAML include until I found the one that had it. Then I cut and pasted each section until I found the section. Then I cut and pasted each entry until I found the entry. I wish there was a better way but now it works.

And it was an indentation error… Yes??
I was going to suggest using the ’ partial reload’ functions to at least find the offending module.

Yeah - and I tried the partial reload, but it was one of the YAMLs that can’t be controlled there. Took a while but figured it out.

Could i ask what is wrong with it?

@lachi3tesn
The light.turn_off service provides no additional data (like brightness).