[Bug Fix] Fix oauth2 token for widget didn't been setup when login - #20404
[Bug Fix] Fix oauth2 token for widget didn't been setup when login#20404tzef wants to merge 1 commit into
Conversation
|
@tzef thanks for the bug fix, I'll review it! 👍 We can target |
1ed685e to
ca194b8
Compare
|
Okay! rebase and update the base branch to trunk |
|
Thanks again for catching and attempting to fix the issue, @tzef!
I agree, tokens shouldn't depend on However, I have a questions:
So, in your testing, defaultBlog is always empty when the user logs? If yes, then do we have a bad timing of I'm wondering if there're more issues related to that then, I see we're setting |
|
Good question! I tried to answer based on my research, cmiiw.
Apparently, there was something wrong in step 3 before, I just found that was fixed in #20394 four days ago 😅, that fixes all extensions not only for the widget extension as my PR. So we can consider
|
|
Thanks for explaining the issue!
Okay, good catch. There were a lot of changes with Core Data and syncing recently, it might've been the reason. That's why I wanted to make sure we're fixing the right thing.
Yes, it could be an option. I'm thinking about whether we would come back to this issue, especially if it wouldn't give an immediate value. I'd say we either finish decoupling defaultBlog and token syncing in this PR, or close it if we don't see a value. Either way, we can prioritize lock screen widgets over this given the rootcause issue is fixed. |
|
Okay!! agree with you, |
Description
The widget extension shares the auth token through the keychain that is configured in the
TodayExtensionService. The auth token is obtained when:The issue happens when the account is changed, because in
AccountService->updateAccountWithID->updateDefaultBlogIfNeeded, we only configure the token if the account has adefaultBlog.However, the defaultBlog is empty when the user just logs in, which means the widget service API token is lost until the next time the token sync-up, resulting in the error response: "The operation couldn't be completed. (Foundation_GenericObjCError error 0.)"
Impact
This issue causes inconsistent results for users, they will see a value of 0 until the app is launched again.
Users may try to click on the widget and be redirected to the stats insight page. The widget value will update at this time, but won't autorefresh because the token is not yet synced. The current time updated value comes from the cache, and the next auto fetch after 30 minutes will keep failing.
It is not severe because it can be recovered when the app is launched again. However, it may be a problem for users with multiple accounts.
Reproduce Steps
Solution
Separate configure widget and configure token, I think it makes sense always configure the token for logged-in users.
For the chase that users without websites, we have checked another config
AppConfiguration.Widget.Stats.userDefaultsSiteIdKeyin the timeline provider to present another status.Testing Instructions
Given logged in account with at least one website and has stats value (not 0)
step 2instead of the default 0 valueRegression Notes
Potential unintended areas of impact
Home screen widgets data fetch
What I did to test those areas of impact (or what existing automated tests I relied on)
As same as Testing Instructions
What automated tests I added (or what prevented me from doing so)
N/A
PR submission checklist:
RELEASE-NOTES.txtif necessary.