home-assistant / my.home-assistant.io

The portal to your home.
https://my.home-assistant.io/
32 stars 19 forks source link

Blueprints imported via generated My HA widget links broken when original link contains spaces. #482

Open changeling opened 3 weeks ago

changeling commented 3 weeks ago

Checklist

Describe the issue you are experiencing

I'm not sure if this belongs to Frontend, or another repo, but this seems the most likely. If this would be better posted elsewhere, please let me know.

As of 2024.8: Beautiful badges!, Blueprints imported via generated My HA widget links no longer work for original links which contains spaces.

For example:

Doesn't import, yields An unknown error occurred: View-Assist Travel Time Blueprint with spaces

Does import successfully: [View-Assist Travel Time Blueprint without spaces]

Describe the behavior you expected

A clean import flow, as demonstrated in the second link.

Steps to reproduce the issue

  1. Attempt to import a Blueprint via an HA Link Generator widget that contains spaces. That is, via a redirected URL containing the link to the file to be imported.

What version of Home Assistant Core has the issue?

2024.8.2

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

Safari Version 17.5 (19618.2.12.11.6)

Which operating system are you using to run this browser?

MacOS Sonoma 14.5 (23F79)

State of relevant entities

No response

Problem-relevant frontend configuration

No response

Javascript errors shown in your browser console/inspector

No response

Additional information

No response

changeling commented 3 weeks ago

Moved to https://github.com/home-assistant/core/issues/124515

steverep commented 2 weeks ago

Are you using https://my.home-assistant.io/create-link/ to create the links? If so, what is your input?

dinki commented 2 weeks ago

@steverep Yes. Input looks like this:

https://raw.githubusercontent.com/dinki/View-Assist/main/View%20Assist%20custom%20sentences/Travel%20Times%20by%20Waze/blueprint-traveltimesbywaze.yaml

Note that these were all working previously but something has changed as all of those previously working links are nonfunctional now presenting 'An error occurred' when attempting to import.

changeling commented 2 weeks ago

@steverep @dinki On this point, I just noticed that https://my.home-assistant.io/create-link/ now refuses to accept https://raw.githubusercontent.com/dinki/View-Assist/main/View%20Assist%20custom%20sentences/Travel%20Times%20by%20Waze/blueprint-traveltimesbywaze.yaml as a valid URL, which it has done in the past.

It will accept this with the %20 replaced with +, which should be a valid space, but the resulting URL has the +s replaced with %2B rather than the correct %20.

Regardless, the resulting redirect URL will still yield an unknown error with the %2Bs replaced with %20s in the parameter URL.

steverep commented 2 weeks ago

So there's definitely at least one bug in that generator I've noticed. The reason it reports the %20 encoded URL as an error is because the HTML input has a type of "text" instead of "url". That should be fixed.

steverep commented 2 weeks ago

The generator also simply does not create the my HA link correctly. The search parameter should look like:

...=https%3A%2F%2Fraw.githubusercontent.com%2Fdinki%2FView-Assist%2Fmain%2FView%2520Assist%2520custom%2520sentences%2FTravel%2520Times%2520by%2520Waze%2Fblueprint-traveltimesbywaze.yaml

In other words, it should just percent encode the % in %20.

steverep commented 2 weeks ago

I've transferred this to the correct repo and assigned myself. Fix is easy enough and I'll get to it shortly. In the meantime, just replace any "+" with "%2520".

changeling commented 2 weeks ago

Thank you for taking this on, Steve. It's much appreciated.

And thanks for moving this, and identifying the repo it belongs to. My apologies for my lack of familiarity with the codebase and where which issue belongs. And now I know.

dinki commented 2 weeks ago

@steverep Yes thank you for workin gon this. I attempted to do as you suggested with the "+" with "%2520" and came up with this:

[![Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.](https://my.home-assistant.io/badges/blueprint_import.svg)](https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fraw.githubusercontent.com%2Fdinki%2FView-Assist%2Fmain%2FView%2520Assist%2520custom%2520sentences%2FTravel%2520Times%2520by%2520Waze%2Fblueprint-traveltimesbywaze.yaml)

When I click the link I get a popup saying "my.home-assistant.io says Invalid parameters given" . Sorry for not fully understanding but should this replacement work as-is right now or is it dependent on you putting in your fix?

changeling commented 1 week ago

Just checking on the status of this issue.

dinki commented 1 week ago

I've transferred this to the correct repo and assigned myself. Fix is easy enough and I'll get to it shortly. In the meantime, just replace any "+" with "%2520".

Hi @steverep . Sorry to be a pain but this breaking change is posing some issues with my project as it is dependent on these blueprints and all of my urls have spaces in them. Should I work towards restructuring my GH to not have spaces to get around this issue or do you think a fix may be available relatively soon? Thanks again.

changeling commented 5 days ago

Checking the status of this.

silamon commented 5 days ago

There's no need to keep posting in this thread for statusses. It's a community driven project, so contributions are mostly done in free time.