Skip to content

Handle pending mail account provisioning case (#1081)#1082

Merged
markstos merged 2 commits into
mainfrom
issue-1081-setup-404
Jul 8, 2026
Merged

Handle pending mail account provisioning case (#1081)#1082
markstos merged 2 commits into
mainfrom
issue-1081-setup-404

Conversation

@markstos

@markstos markstos commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Appointment can call the CalDAV setup endpoint after subscription 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, so the old flow could throw AccountNotFoundError.

Return a machine-readable 409 mail_account_not_ready response for that transient state where user.stalwart_primary_email is not set.

We will continue to throw on other Stalwart lookup failures, as those remain unexpected.

Applicable Issues

QA Log

  • Confirmed we have test coverage for this route.
    • ( src/thunderbird_accounts/mail/tests/test_views.py:999, AppointmentCalDAVSetupTestCase.)

Appointment can call the CalDAV setup endpoint after subscription 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, so the old flow could throw AccountNotFoundError.

Return a machine-readable 409 `mail_account_not_ready` response for that transient state where user.stalwart_primary_email is not set.

We will continue to throw on other Stalwart lookup failures, as those remain unexpected.

@davinotdavid davinotdavid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you! Code diff lgtm but I think we should add a test for this as there's no coverage for this exact case with the status 409 and code mail_account_not_ready.

Even though it is a small enough change, since Appointment will rely on this in its counterpart implementation, we should harden this in tests.

@markstos markstos requested a review from davinotdavid July 8, 2026 20:52

@davinotdavid davinotdavid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

@markstos markstos merged commit 0f6f759 into main Jul 8, 2026
8 checks passed
@markstos markstos deleted the issue-1081-setup-404 branch July 8, 2026 21:05
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.

Evaluate if /caldav/setup/ AccountNotFoundError should raise an exception or return 404 and log

2 participants