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
Handle GeoJSON int to str conversion when the name is an int #108937
Conversation
Hey there @exxamalte, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
38cea7d
to
10c8883
Compare
10c8883
to
333769d
Compare
a833ed2
to
e3e7e49
Compare
I have seen some GeoJSON feeds that use capitalised name (`Name`) and some feeds that use non-capitalised name (`name`). The GeoJSON spec itself doesn't speak to this as these are optional (albeit, often used) `properties`. Follow on from home-assistant#108937.
I have seen some GeoJSON feeds that use capitalised name (`Name`) and some feeds that use non-capitalised name (`name`). The GeoJSON spec itself doesn't speak to this as these are optional (albeit, often used) `properties`. Follow on from home-assistant#108937.
I was just thinking of an alternative where we enforce this type conversion to |
I think that would be a good change (especially considering that the lib already claims to return |
I have done some further investigating. It turns out that the code which was causing this error (below): core/homeassistant/util/__init__.py Lines 43 to 48 in a793a54
Passes on any values from the entity name, including those names that are not str (as we are doing here with int), to the function Should we not fix it at the root then (rather than in each integration)? Maybe I should raise a separate PR for that. |
Closing in favour of #108989. Will re-open this if that one was not accepted. |
I think we were trending in right direction with this PR, as an entity's core/homeassistant/helpers/entity.py Line 720 in a793a54
int and try to fix things downstream in the slugify call.
|
So what’s the proposal from here? All checks pass already and we handle the int scenario. |
Resolves error: Logger: homeassistant Source: util/__init__.py:47 First occurred: 17:07:48 (3956 occurrences) Last logged: 17:17:41 Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 658, in _async_add_entity entry = entity_registry.async_get_or_create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 661, in async_get_or_create entity_id = self.async_generate_entity_id( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 581, in async_generate_entity_id preferred_string = f"{domain}.{slugify(suggested_object_id)}" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 47, in slugify slug = unicode_slug.slugify(text, separator=separator) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/slugify/slugify.py", line 104, in slugify text = _unicode(text, 'utf-8', 'ignore') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: decoding to str: need a bytes-like object, int found Co-Authored-By: Chris Roberts <NasaGeek@users.noreply.github.com>
8516e5c
to
5e9b187
Compare
I have incorporated all of the feedback now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @codyc1515! I'm happy where this ended up.
If this PR is not merged soon, 2024.2 release will be broken for some GeoJSON users. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @codyc1515 👍
../Frenck
…sistant#108937) Co-authored-by: Chris Roberts <NasaGeek@users.noreply.github.com>
Proposed change
Handles an error that could occur on setting up the config entry when generating the entity_id slug from the name if the name from the GeoJSON feed was an int (not a str).
This was an unexpected regression from #108753 and should be included before the new release in order to avoid breaking the integration unexpectedly.
Type of change
Additional information
Checklist
ruff format homeassistant tests
)To help with the load of incoming pull requests: