fix(gateway): correct ws scheme conversion for https urls#18984
Closed
CharlieKerfoot wants to merge 1 commit into
Closed
fix(gateway): correct ws scheme conversion for https urls#18984CharlieKerfoot wants to merge 1 commit into
CharlieKerfoot wants to merge 1 commit into
Conversation
Collaborator
|
Merged via PR #19182. Trivial but critical — swap the replace order to prevent https mangling. Thanks @CharlieKerfoot! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In
gateway/platforms/homeassistant.py:142, the WebSocket URL conversion replacedhttp://beforehttps://, so anhttps://Home Assistant URL becamews://s://...and the connection failed before auth.Fix
Swap the order so
https://is replaced withwss://first, thenhttp://withws://. Thehttpscase no longer matches thehttpprefix because it has already been rewritten.Tests
Verified manually by pointing
_hass_urlat anhttps://instance and confirming the resultingws_urliswss://.../api/websocketand the WebSocket handshake succeeds;http://URLs still convert tows://as before.