Skip to content

Ask for the email in the reauth flow, and add a reconfigure step - #4

Merged
AboveColin merged 2 commits into
mainfrom
fix/reauth-missing-email
Sep 15, 2026
Merged

AboveColin merged 2 commits into
mainfrom
fix/reauth-missing-email

Conversation

@AboveColin

Copy link
Copy Markdown
Owner

What broke

Reconfiguring the Fitdays entry on my dev instance showed "Unexpected error." Three receipts:

  • home-assistant.logERROR [custom_components.fitdays.config_flow] Unexpected Fitdays error during login: email and password are required
  • the entry's stored data — {'email': None, 'password_hash': None, 'refresh_token': None, 'token': SET, 'uid': SET}
  • fitdays/client.py:109if not email or not password: raise FitdaysValidationError("email and password are required")

async_step_reauth_confirm asked only for the password and reused the email stored on the entry. With no email on the entry it passed "" to FitdaysClient.login, the client raised FitdaysValidationError before contacting the cloud, and the except FitdaysError branch mapped it to the unknown key, which strings.json renders as "Unexpected error." The entry could not be recovered from the UI at all.

There was also no async_step_reconfigure, so the entry could not be pointed at fresh credentials.

What changed

  • The reauth form asks for the email too, prefilled from the entry when it has one.
  • FitdaysValidationError maps to invalid_auth. Blank input is a form problem, not an outage.
  • New async_step_reconfigure taking email, password and country. It aborts with account_mismatch when the returned uid differs from the entry's unique_id, because reconfigure repairs one account's entry and a second account belongs in its own entry.
  • _credentials_schema() builds the one form all three steps use.
  • strings.json and translations/en.json gain the reconfigure step and the reconfigure_successful and account_mismatch aborts.

Verified on ha-dev

HA 2026.8.3, podman container ha-dev on nix1, running this branch's files.

  • the entry reports supports_reconfigure: true
  • POST /api/config/config_entries/flow with the entry id returns step_id: reconfigure with fields email (required), password (password selector), country (optional, default NL)
  • submitting a blank email, the exact input that produced "Unexpected error.", returns errors {"base": "invalid_auth"} on both the reconfigure and the reauth step
  • grep -c 'Unexpected Fitdays error' on the log after those submits: 0

The successful-login path is not exercised, because the dev entry holds an expired hand-seeded token with no credentials and I have no Fitdays account credentials to hand.

Independent of #3; branched from main.

🤖 Generated with Claude Code

async_step_reauth_confirm asked only for the password and reused the email
stored on the config entry. An entry whose data carries no email, which is
what an entry written before the email was stored looks like, then passed an
empty string to FitdaysClient.login. The client raises FitdaysValidationError
at client.py:109 before it contacts the cloud, the flow mapped that to the
"unknown" error key, and the form showed "Unexpected error." with no way to
recover the entry.

The reauth form now asks for the email as well, prefilled from the entry when
it has one. FitdaysValidationError maps to invalid_auth, because blank input
is a form problem and not an outage.

The flow also had no async_step_reconfigure, so the entry could not be pointed
at fresh credentials at all. Added one. It refuses credentials whose uid
differs from the entry's unique_id, because reconfigure repairs one account's
entry and a second account belongs in its own entry.

Verified on ha-dev (HA 2026.8.3, podman container ha-dev on nix1):
- the entry now reports supports_reconfigure true
- the reconfigure form renders email (required), password (password selector),
  country (optional, default NL)
- submitting a blank email, the exact input that produced "Unexpected error.",
  returns errors {"base": "invalid_auth"} on both the reconfigure and the
  reauth step, and logs no ERROR line

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 0b3faa7b-a573-4f97-9efb-4dc86ce7fbbf


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

nl.json still described the reauth step as password-only and had no
reconfigure step, so a Dutch user would have seen the new email field and
the reconfigure form fall back to English. The key sets of en.json and
nl.json now match exactly, checked by comparing them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@AboveColin
AboveColin merged commit 853c5d6 into main Sep 15, 2026
5 checks passed
@AboveColin
AboveColin deleted the fix/reauth-missing-email branch September 15, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant