fix: Use reauth_entry.data instead of undefined self.data in reauth flow#318
fix: Use reauth_entry.data instead of undefined self.data in reauth flow#318
Conversation
The reauth flow was trying to access self.data[CONF_USER_ID] but self.data is never set during reauth, causing a KeyError. Fixed by using self.reauth_entry.data[CONF_USER_ID] instead.
ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
User description
Summary
Fix a bug in the re-authentication flow where
self.datawas used instead ofself.reauth_entry.data.Bug
In
async_step_reauth_confirm, when the client wasn't initialized yet, the code attempted to accessself.data[CONF_USER_ID], butself.datais never set during the reauth flow. This would cause aKeyError.Fix
Changed line 284 from:
to:
Also added an assertion to ensure
self.reauth_entryis not None before accessing it.PR Type
Bug fix
Description
Fix KeyError in reauth flow by using correct data source
Replace undefined
self.datawithself.reauth_entry.dataAdd assertion to ensure
self.reauth_entryis not NoneImprove code reliability during re-authentication process
Diagram Walkthrough
File Walkthrough
config_flow.py
Fix reauth flow data access in async_step_reauth_confirmcustom_components/iec/config_flow.py
self.data[CONF_USER_ID]was accessed butself.dataisnever set during reauth flow
self.reauth_entry.data[CONF_USER_ID]to access thecorrect data source
self.reauth_entryis not None beforeaccessing its data