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

File "<frozen runpy>", line 198, in _run_module_as_main #113127

Closed
Superzite opened this issue Mar 12, 2024 · 22 comments
Closed

File "<frozen runpy>", line 198, in _run_module_as_main #113127

Superzite opened this issue Mar 12, 2024 · 22 comments

Comments

@Superzite
Copy link

The problem

UI won't start...

2024-03-12 02:47:34.728 ERROR (MainThread) [root] Uncaught exception
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/usr/src/homeassistant/homeassistant/main.py", line 221, in
sys.exit(main())
^^^^^^
File "/usr/src/homeassistant/homeassistant/main.py", line 209, in main
exit_code = runner.run(runtime_conf)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/runner.py", line 188, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 685, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/runner.py", line 154, in setup_and_run_hass
hass = await bootstrap.async_setup_hass(runtime_config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 230, in async_setup_hass
await async_from_config_dict(config_dict, hass) is not None
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 349, in async_from_config_dict
await async_load_base_functionality(hass)
File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 324, in async_load_base_functionality
await asyncio.gather(
File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 1290, in async_load
await hass.data[DATA_REGISTRY].async_load()
File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 1124, in async_load
entities[entity["entity_id"]] = RegistryEntry(
~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 473, in setitem
self._index[(entry.domain, entry.platform, entry.unique_id)] = entry.entity_id
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unhashable type: 'list'

What version of Home Assistant Core has the issue?

Core 2024.3.0

What was the last working version of Home Assistant Core?

Unsure - Tried downgrade still same problem

What type of installation are you running?

Home Assistant OS

Integration causing the issue

don't now

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@Superzite
Copy link
Author

Did try the command:

jq -r '.data.entries[] | select(.unique_id | type == "array") | {unique_id, domain}' /config/.storage/core.config_entries

But didnt get any output.

@joostlek
Copy link
Member

that means an entry has a non serializable unique_id. This can either be caused by the unique_id type to be dict or array. maybe change your jq to check dict as well. (I am not jq expect, but what does the | {unique_id, domain} mean?

@Superzite
Copy link
Author

Superzite commented Mar 12, 2024

See that friend of mine got the same error today.. Suspect that https://github.com/Danielhiversen/home_assistant_min_renovasjon/issues/new is the cause of the problem, how do I do a rollback from console ? The UI do not work..

@joostlek
Copy link
Member

Latest version doesn't look wrong. You should find out what entities have this unserializable unique_id and remove it, other wise you keep this

@Superzite
Copy link
Author

that means an entry has a non serializable unique_id. This can either be caused by the unique_id type to be dict or array. maybe change your jq to check dict as well. (I am not jq expect, but what does the | {unique_id, domain} mean?

Am not sure what am excepting to get for this, found it on another tread that got similar error, so just trying, am not very
familiar whit Consol and CLI work on home assistant

@Superzite
Copy link
Author

Latest version doesn't look wrong. You should find out what entities have this unserializable unique_id and remove it, other wise you keep this

How do I find it and how do a remove it when I don't have UI ?

@joostlek
Copy link
Member

Ooooh, wait. You need to check another file.

jq -r '.data.entities[] | select(.unique_id | type == "array") | {unique_id, platform}' /config/.storage/core.entity_registry

@Superzite
Copy link
Author

jq -r '.data.entities[] | select(.unique_id | type == "array") | {unique_id, platform}' /config/.storage/core.entity_registry

Result:
jq: error (at core.entity_registry:561491): Cannot iterate over null (null)

@joostlek
Copy link
Member

something is strange with that file. Mind mailing it to me?

@joostlek
Copy link
Member

If you send it on the mail to me I can take a better look. The only personal information contained in that file would be any unique_id (but that's probably what we are looking after so no point in removing them) or entity names.

@Superzite
Copy link
Author

Email sendt. :-) Hope you find the problem.

@joostlek
Copy link
Member

Yep, it's min_renovasjon. The error came because you probably didn't completely copy paste the command. You should edit that file, remove everything in from line 559725 until 559798. (This is important, the lines I mentioned don't completely follow the { }, but this list should end with a } and not a },)

Then remove the custom component and start your HA again

@Superzite
Copy link
Author

Superzite commented Mar 12, 2024 via email

@joostlek
Copy link
Member

When you check the error logs, do you see anything that sounds like "stuff didn't work, corrupt something" because I think something went wrong with that file and remade the file, causing it to reset everything

@Superzite
Copy link
Author

Yes... Seems like you got that right... Can I stop Core and copy the file back and do this one more time ?

Think I missed a character error : unexpected character: line 559727 column 7 The old file is ... core.entity_registry.corrupt.2024-03-12T12:37:33.659361+00:00

@joostlek
Copy link
Member

I think so yes. again, please make sure you remove the right lines. Maybe verify it by running the jq query again (please copy paste right one)

@Superzite
Copy link
Author

Yes.. Now it is up and running... Thx a lot for the help..

But I think "min Renovasjon" got an error in the last update.As a friend of min got the same error.. The update did came out yesterday ..

@joostlek
Copy link
Member

The code you sent me looked correct, so I am not sure what is up with that. But please report it at their repository.

I have notified others of this issue and they might look into making sure this doesn't happen anymore.

I'll close this now.

@nitefly80
Copy link

Hello,
I am having the same error as Superzite.
I ran the command:
jq -r '.data.entities[] | select(.unique_id | type == "array") | {unique_id, platform}' /config/.storage/core.entity_registry
and got results that point to "Min Renovasjon"
But I am unsure what to remove from the /config/.storage/core.entity_registry
Any tips ?

@joostlek
Copy link
Member

All the entries from that file with that as the platform. It should still be a valid json file.

@nitefly80
Copy link

Thank you :)
Sorry Im kind of lost here, but I will give it a try.

@nitefly80
Copy link

Thank you Joostlek, Im up and running. Seems like everything is working ok!

thank you so much:)

@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants