Skip to content

Report Rohlík's "confirm your login by e-mail" (login status 202) as an actionable message instead of a generic error #86

Description

@dvejsada

Background

Rohlík's login endpoint can answer {"status": 202, "messages": [], "data": null} — the login was accepted but is not complete until the user clicks a link Rohlík e-mails them, so no session is issued. Their login page carries the matching copy ("Pro dokončení přihlášení klikněte na odkaz, který jsme vám poslali na adresu {{email}}" / "Zbývá jen potvrdit e-mail"), and they have magicLink → /magic-login/keep-account and /verification/email routes. Full analysis in #79.

This is account-level state on Rohlík's side, so it is not something the integration can satisfy itself — the user has to act in their mailbox.

Current behaviour

rohlik-api collapses this into a bare RohlikAPIError whose message degenerates to "Unknown error occurred during login: Unknown error", dropping the status code (upstream: dvejsada/rohlik_api_python#8).

  • Config flow / reauth (config_flow.py:84, config_flow.py:147): except RohlikAPIError → cannot_connect → "Failed to connect to Rohlik.cz". Actively misleading — the connection is fine, and the user goes off debugging their network. On v0.5.0 the same case surfaced as "Neočekávaná chyba" (Neočekávaná chyba #79).
  • Runtime (hub.py:476): RohlikAPIError → UpdateFailed, so a 202 on a re-login makes the integration retry forever and sit there unavailable, with nothing telling the user why.

What to do

Blocked on dvejsada/rohlik_api_python#8 landing (dedicated error type / status on the exception), then here:

  1. Split the error mapping in the config and reauth flow:
    • InvalidCredentialsError → invalid_auth
    • APIRequestFailedError → cannot_connect (genuine network failures)
    • the incomplete-login error → a new login_not_confirmed string, e.g. "Rohlík.cz needs this login confirmed. Open the link Rohlík just e-mailed to your address, then try again." — added to both translations/en.json and translations/cs.json.
  2. Handle it at runtime too, rather than retrying silently: raise a repair issue (homeassistant.helpers.issue_registry) carrying the same instruction, since this needs the user to do something outside Home Assistant. ConfigEntryAuthFailed is the alternative, but the reauth dialog asks for a password that is not the actual problem.
  3. Keep a test for each mapping so the "cannot_connect" regression cannot come back.

Notes

The 202 semantics are inferred from Rohlík's frontend, not from documentation — see #79 for exactly what is verified (including that the request shape is not the cause: a cookie-less POST with the library's User-Agent returns a proper 401 for bad credentials). Worth confirming against a real 202 before shipping the user-facing wording.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions