Repository navigation
fix: normalise username case before Cognito login - #179
Open
matt-thepie wants to merge 1 commit into
Open
matt-thepie wants to merge 1 commit into
matt-thepie wants to merge 1 commit into
Conversation
Hive's Cognito pool treats the email as case-sensitive, so a capitalised address (for example from mobile autocapitalisation) fails with HiveInvalidPassword even though the account exists. Store the username trimmed and lower-cased via a property on both auth classes, so the constructor and start_session's reassignment from the Home Assistant config entry are both covered. Fixes home-assistant/core#185593 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Problem
home-assistant/core#185593: Hive login fails if the email is typed with any capital letter, for example when the iOS app autocapitalises the first letter. Hive's Cognito pool treats the username as case-sensitive and answers with
NotAuthorizedException, which surfaces asHiveInvalidPassword.Home Assistant only partly works around this.
config_flow.pylower-cases the username for the flow's ownAuth(...):but
self.data.update(user_input)keeps the typed value, and that is what is saved in the config entry. On every start,__init__.pypasses the entry to the library:and
start_sessioncopies it straight onto the auth object (self.auth.username = config["username"]), so any later password or device login uses the capitalised address and fails.Fix
HiveAuthAsyncandHiveAuthnow exposeusernameas a property whose setter stores the value trimmed and lower-cased. This covers both the constructor and the reassignment instart_session, with no Home Assistant change needed. File mode (use@file.com) is detected regardless of case as a side effect.Verification
Live, against a real Hive account with saved device credentials:
HiveInvalidPasswordHiveInvalidPasswordtests/unit/test_hive_auth_async.pyandtests/unit/test_hive_auth.pycover the constructor, reassignment, theUSERNAMEsent toInitiateAuth, and file-mode detection.PLR0917hits are pre-existing on untouched lines and also appear ondev..secrets.baselineupdated because the new property shifts an allowlisted line inhive_auth_async.py.Home Assistant impact
No public API change.
Auth,startSessionand the exceptions raised are unchanged, and nothing in the integration readsauth.usernameback. Checkedhomeassistant/components/hive/config_flow.pyand__init__.pyondev.🤖 Generated with Claude Code