home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.03k stars 31.06k forks source link

My Home Assistant links with spaces get mangled in Android app #118652

Open lindhe opened 5 months ago

lindhe commented 5 months ago

The problem

I'm trying to import a blueprint from GitHub in the Android app. It fails to render a preview and does not let me proceed with adding it. Seems to work fine in the web/desktop application. Turns out it's because I get the wrong URL in the app.

The real URL to the blueprint is this: https://github.com/SgtBatten/HA_blueprints/blob/main/Frigate Camera Notifications/Stable The URL I get in the app is this: https://github.com/SgtBatten/HA_blueprints/blob/main/Frigate+Camera+Notifications/Stable

So somewhere along the lines, spaces get converted to +. I'm guessing it's in the Home Assistant app, but I'm not sure. Could be Android's handling of app links too.

What I'm doing:

  1. Go to https://community.home-assistant.io/t/frigate-mobile-app-notifications-2-0/559732 in a web browser on Android.
  2. Click on the import link for "Stable" (on Firefox: long-click and select "Open link in external app").
  3. Click "Open link" when presented in Home Assistant app.
  4. Inspect the URI in the "Blueprint address" field.

Trying to create a more minimal example, I went to https://my.home-assistant.io/create-link/ and entered https://example.com/foo bar as the URL. That gets translated into https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fexample.com%2Ffoo+bar which clearly has a + between foo and bar. But if I go to https://community.home-assistant.io/t/frigate-mobile-app-notifications-2-0/559732 and copy his link from there the space is URL encoded (%20) so I don't know what to think. :confused:

What version of Home Assistant Core has the issue?

core-2024.5.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

My Home Assistant

Link to integration documentation on our website

https://www.home-assistant.io/integrations/my/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

I only get this error in the logs, but it's clearly because it's using the incorrect URL:

Logger: homeassistant.components.websocket_api.http.connection
Source: components/blueprint/importer.py:168
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 19:31:39 (1 occurrences)
Last logged: 19:31:39

[139673598921152] Error handling message: Unknown error (unknown_error) Andreas Lindhé from 10.0.20.36 (Mozilla/5.0 (Linux; Android 14; SM-S911B Build/UP1A.231005.007; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/125.0.6422.82 Mobile Safari/537.36 Home Assistant/2024.4.1-12576 (Android 14; SM-S911B))
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/blueprint/websocket_api.py", line 77, in ws_import_blueprint
    imported_blueprint = await importer.fetch_blueprint_from_url(hass, msg["url"])
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/blueprint/importer.py", line 257, in fetch_blueprint_from_url
    imported_bp = await func(hass, url)
                  ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/blueprint/importer.py", line 168, in fetch_blueprint_from_github_url
    resp = await session.get(import_url, raise_for_status=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 696, in _request
    resp.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1070, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url=URL('https://raw.githubusercontent.com/SgtBatten/HA_blueprints/main/Frigate+Camera+Notifications/Stable')

Additional information

I cannot wrap my head around why I get different behavior in Android and on the web. :thinking: Maybe something with how Android handles "open in app"? I've tried to navigate to the link using both Firefox and Chrome on Android and the result is the same, so I'm pretty sure either Android or Home Assistant is at fault here.

home-assistant[bot] commented 5 months ago

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (my) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `my` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign my` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


my documentation my source (message by IssueLinks)

issue-triage-workflows[bot] commented 2 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

lindhe commented 2 months ago

Please keep this open!

etiennec78 commented 2 months ago

Hello, just wanted to let you know that there is another issue opened for this bug : https://github.com/home-assistant/my.home-assistant.io/issues/482

lindhe commented 2 months ago

Thanks for finding that!

@steverep it seems like my issue is older and with slightly more debug information in the OP, but discussions have progressed further in https://github.com/home-assistant/my.home-assistant.io/issues/482 right now. Should we close my issue and continue there, or do we keep both issues?

It is not clear to me if this is a core issue or not, considering it seems like the spaces in the link changes when handled by the Android app.