Home Assistant Container not starting - Could not parse JSON file in .storage

Hello there,

I’m running Home Assistant using a Docker container in OpenWRT arm64 (OpenWrt SNAPSHOT r18913-b0d5939b80 Linux OpenWRT-RPi 5.10.100 #0 SMP Sat Feb 19 18:34:18 2022 aarch64 GNU/Linux) from the following image and docker-compose configuration:

  homeassistant:
        privileged: true
        restart: unless-stopped
        environment:
            - TZ=America/Mexico_City
        volumes:
            - '/usbstick/HomeAssistant:/config'
        network_mode: host
        image: 'ghcr.io/home-assistant/home-assistant:stable'

Since a few weeks ago, the container has been on a constant reboot loop claiming problems with both core.device_registry and core.config_entries, looping the following log output even after backing up and replacing said files with both empty contents and { } as a string:

2022-02-28 21:23:33 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /config/configuration.yaml contains duplicate key "device_tracker". Check lines 20 and 28
2022-02-28 21:23:33 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /config/configuration.yaml contains duplicate key "sensor". Check lines 83 and 118
2022-02-28 21:23:33 ERROR (SyncWorker_0) [homeassistant.util.json] Could not parse JSON content: /config/.storage/core.config_entries
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 33, in load_json
    return json.loads(fdesc.read())  # type: ignore
  File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/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)
2022-02-28 21:23:33 ERROR (MainThread) [root] Uncaught exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 33, in load_json
    return json.loads(fdesc.read())  # type: ignore
  File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/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)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 203, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 191, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 119, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/usr/src/homeassistant/homeassistant/runner.py", line 101, in setup_and_run_hass
    hass = await bootstrap.async_setup_hass(runtime_config)
  File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 131, in async_setup_hass
    await async_from_config_dict(config_dict, hass) is not None
  File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 209, in async_from_config_dict
    await hass.config_entries.async_initialize()
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 904, in async_initialize
    config = await self.hass.helpers.storage.async_migrator(
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 42, in async_migrator
    if (store_data := await store.async_load()) is not None:
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 114, in async_load
    return await self._load_task
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 123, in _async_load
    return await self._async_load_data()
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 141, in _async_load_data
    data = await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 39, in load_json
    raise HomeAssistantError(error) from error
homeassistant.exceptions.HomeAssistantError: Expecting value: line 1 column 1 (char 0)
[finish] process exit code 1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.

(Full log wouldn’t even fit within the character limit)

So far the only other instances I’ve found while researching of this bug were these two, but even though I followed the advice of both threads, I haven’t been able to get out of the loop even after recreating the container.

Is there anything else I could try to look for?

Attaching generated log files below:

homeassistant.log

2022-02-28 21:28:05 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /config/configuration.yaml contains duplicate key "device_tracker". Check lines 20 and 28
2022-02-28 21:28:05 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /config/configuration.yaml contains duplicate key "sensor". Check lines 83 and 118
2022-02-28 21:28:05 ERROR (SyncWorker_0) [homeassistant.util.json] Could not parse JSON content: /config/.storage/core.config_entries
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 33, in load_json
    return json.loads(fdesc.read())  # type: ignore
  File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/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)

homeassistant.log.1

2022-02-28 21:26:57 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /config/configuration.yaml contains duplicate key "device_tracker". Check lines 20 and 28
2022-02-28 21:26:57 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /config/configuration.yaml contains duplicate key "sensor". Check lines 83 and 118
2022-02-28 21:26:57 ERROR (SyncWorker_0) [homeassistant.util.json] Could not parse JSON content: /config/.storage/core.config_entries
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 33, in load_json
    return json.loads(fdesc.read())  # type: ignore
  File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/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)

homeassistant.log.fault

 

look like you have duplicate items in your config file.

look in your config and fix that. possibly run it through a json validator to verify it is valid jsonay

EDIT

do you have “includes” in your config?
is it possible you include device tracker file and also have device tracker somewhere in main config. What about “sensor”?

https://www.home-assistant.io/docs/configuration/devices/ explains the problem, you can’t have multiple sensor: lines (or anything else).

Any time you edit YAML you should run a command line configuration check to spot errors like that. The UI check will miss many of them.

Hello, you were right.

I thought since it was only a warning I could deal with that later, but went ahead and modified my configuration.yaml to remove the duplicated entries. Regarding validation, I’m currently unable to attempt it given that the container is still stuck in a reboot loop even after fixing the duplicates, but I presume it to be fixed given there’s no longer any mention of them in the container logs.

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[finish] process exit code 256
[finish] process received signal 15
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
2022-03-02 21:37:40 ERROR (SyncWorker_0) [homeassistant.util.json] Could not parse JSON content: /config/.storage/core.config_entries
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 33, in load_json
    return json.loads(fdesc.read())  # type: ignore
  File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/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)
2022-03-02 21:37:40 ERROR (MainThread) [root] Uncaught exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 33, in load_json
    return json.loads(fdesc.read())  # type: ignore
  File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/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)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 203, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 191, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 119, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/usr/src/homeassistant/homeassistant/runner.py", line 101, in setup_and_run_hass
    hass = await bootstrap.async_setup_hass(runtime_config)
  File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 131, in async_setup_hass
    await async_from_config_dict(config_dict, hass) is not None
  File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 209, in async_from_config_dict
    await hass.config_entries.async_initialize()
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 904, in async_initialize
    config = await self.hass.helpers.storage.async_migrator(
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 42, in async_migrator
    if (store_data := await store.async_load()) is not None:
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 114, in async_load
    return await self._load_task
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 123, in _async_load
    return await self._async_load_data()
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 141, in _async_load_data
    data = await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 39, in load_json
    raise HomeAssistantError(error) from error
homeassistant.exceptions.HomeAssistantError: Expecting value: line 1 column 1 (char 0)
[finish] process exit code 1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
2022-03-02 21:37:49 ERROR (SyncWorker_0) [homeassistant.util.json] Could not parse JSON content: /config/.storage/core.config_entries
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 33, in load_json
    return json.loads(fdesc.read())  # type: ignore
  File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/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)
2022-03-02 21:37:49 ERROR (MainThread) [root] Uncaught exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 33, in load_json
    return json.loads(fdesc.read())  # type: ignore
  File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/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)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 203, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 191, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 119, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/usr/src/homeassistant/homeassistant/runner.py", line 101, in setup_and_run_hass
    hass = await bootstrap.async_setup_hass(runtime_config)
  File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 131, in async_setup_hass
    await async_from_config_dict(config_dict, hass) is not None
  File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 209, in async_from_config_dict
    await hass.config_entries.async_initialize()
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 904, in async_initialize
    config = await self.hass.helpers.storage.async_migrator(
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 42, in async_migrator
    if (store_data := await store.async_load()) is not None:
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 114, in async_load
    return await self._load_task
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 123, in _async_load
    return await self._async_load_data()
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 141, in _async_load_data
    data = await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 39, in load_json
    raise HomeAssistantError(error) from error
homeassistant.exceptions.HomeAssistantError: Expecting value: line 1 column 1 (char 0)
[finish] process exit code 1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.

if there’s anything else I should check please let me know, and thanks for the help!

fix this file.

I not sure but to fix same error below person just renamed the file…i assume this will force HA to recreate it. You could also just open the file and check it for errors or run it through json validator and remove errors

1 Like

Hi, sadly that didn’t seem to help much when I attempted it on my environment.

As I’ve said before, I mv’d the problematic file over to a backup copy and attempted to run the container with both an empty text file on its name and an empty JSON object. I just tried letting the container recreate the file itself and the results stay consistent with the previously observed behavior.

Given said conditions, I’m not too sure what could I try next now that the error just repeats every time the container restarts, but if anyone has any ideas I’m all ears.

what about NO file?

Also…“As I’ve said before”…I thought original problem was with config file.
The error you just posted is different file, entity file.

Just told you it didn’t work either.

The problem has always been about the .core.config_entries, given that as the title of the post states they are JSON syntax files as opposed to the YAML syntax used for the configuration entries in the working environment. Even still, I mentioned them as so in the first post:

And even linked to some proposed solutions I found while researching the forum for similar behavior:

I understand that the warning in the attached logs mentioned some duplicated entries for the configuration.yaml file, but given those have been corrected already and the previously stated problem persists, I believe the thread should still be in good standing now that we have clarified the origin of the problem. If there’s anything else I should add, please let me know.

Look through the files in /config/.storage/

I was able to find a file, core.device_registry, that had corrupted itself when I did a host restart. Renaming this to .old and running ha core restart from ssh got mine going again.