Skip to content

Bug 1868418 - Rerun ensure capabilities after logging in - #7457

Merged
bendk merged 1 commit into
mozilla:mainfrom
bendk:bdk/push-ywlrwvrlttxo
Jul 8, 2026
Merged

Bug 1868418 - Rerun ensure capabilities after logging in#7457
bendk merged 1 commit into
mozilla:mainfrom
bendk:bdk/push-ywlrwvrlttxo

Conversation

@bendk

@bendk bendk commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Moved the code to RetryingAccount, which should give us this functionality for free.

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

@bendk
bendk requested a review from skhamis June 30, 2026 15:29
@bendk

bendk commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

I think I got the state machine stuff right, but please double-check my work here.

@bendk
bendk force-pushed the bdk/push-ywlrwvrlttxo branch 2 times, most recently from 5fd30b9 to be1a391 Compare June 30, 2026 18:35

@skhamis skhamis 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 fix! I think we're close but just one question about the error part

Ok(if active { S::Connected } else { S::AuthIssues })
}
match account.finish_initialize(&device_config.capabilities) {
Ok(()) => Ok(S::Connected),

@skhamis skhamis Jul 1, 2026

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.

One thing worth checking: in the old code we land at S::AuthIssues when check_authorization_status comes back false. The new code propagates the original FxaError::Authentication to the Err(cause) arm, which sends us to S::Disconnected?. For someone who is signed-in and whose refresh token is server-invalidated (password-changed elsewhere), I think our AuthIssues preserves the account state and lets consumers show the "re-auth" flow. Disconnected will put them back to full sign-in right?
Should we do something like:

 match account.finish_initialize(&device_config.capabilities) {
                         Ok(()) => Ok(S::Connected),
                        Err(cause) => {
                            let target = if matches!(cause.get_error_handling().err, FxaError::Authentication) {
                                S::AuthIssues
                            } else {
                                S::Disconnected
                            };
                            Err(StateMachineErr::new(cause, target))
                        }
                    }

or something similar? However if i'm missing something here please let me know!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That seems like an improvement, but maybe it should always be S::AuthIssues. I think that's what the current code does and it seems more correct to me. WDYT?

Moved the code to RetryingAccount, which should give us this
functionality for free.

Also, tweaked the fxa-client example a bit.
@bendk
bendk force-pushed the bdk/push-ywlrwvrlttxo branch from be1a391 to 2016db7 Compare July 7, 2026 20:16
@bendk
bendk requested a review from skhamis July 7, 2026 20:16

@skhamis skhamis 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.

Thanks for making that change. I agree with the new direction and think its "more correct". LGTM!

@bendk

bendk commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Dependency checks seem unrelated to this PR, I didn't change Cargo.lock at all. I'm going to hit the merge button anyways.

@bendk
bendk added this pull request to the merge queue Jul 8, 2026
Merged via the queue into mozilla:main with commit db4e7ef Jul 8, 2026
14 of 15 checks passed
@bendk
bendk deleted the bdk/push-ywlrwvrlttxo branch July 8, 2026 16:37
jonesetc pushed a commit to jonesetc/application-services that referenced this pull request Aug 12, 2026
Moved the code to RetryingAccount, which should give us this
functionality for free.

Also, tweaked the fxa-client example a bit.
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.

2 participants