Skip to content

Gracefully handle case when Account is active but Stalwart is not setup #1739

Description

@markstos

Appointment can call the CalDAV setup endpoint after subscription activation has marked a user active, but before the async Stalwart account provisioning task has completed. In that window the user has no local primary Stalwart email yet, and thunderbird-accounts could throw an AccountFoundFoundError.

A better user experience is a two part fix.

On the thunderbird-accounts side, we'll start to return an HTTP 409 for this transitional state. Here on the accounts side, the backend can notice that state and retry (poll) for a bit until the the account is ready, possibly displaying some kind of "please wait" intermediate UI.

Recommended Appointment-side change

When Appointment’s backend calls POST /appointment/caldav/setup/, treat 409 as transient.

Appointment should not surface that as a “not found” or generic setup failure. It shouldwait and retry.

Implement it on the Appointment backend, not the browser, because this endpoint uses the shared Appointment secret. The Appointment frontend can poll its own backend or show a “finishing
account setup” state while the backend retries Thunderbird Accounts.

Suggested retry behavior:

  • Retry only for 409 with code === "mail_account_not_ready".
  • retry every 5 seconds
  • Cap retries with a reasonable timeout, maybe 60-120 seconds.
  • After timeout, show a soft failure like “Your mail account is still being prepared. Try again in
    a minute.”

Related PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions