Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users are logged out after SDK upgrade #1158

Closed
4 tasks done
PLR2388 opened this issue Apr 5, 2022 · 21 comments · Fixed by #1168
Closed
4 tasks done

Users are logged out after SDK upgrade #1158

PLR2388 opened this issue Apr 5, 2022 · 21 comments · Fixed by #1168
Labels
bounty:$50 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@PLR2388
Copy link

PLR2388 commented Apr 5, 2022

New Issue Checklist

Issue Description

ParseUser.getCurrentUser() becomes null after an update from 1.25.0 to 3.0.0.

Steps to reproduce

  • Log in to an app with 1.25.0
  • Update your app with parse 3.0.0
  • See that you're logout

Actual Outcome

I'm logout

Expected Outcome

I should be login as before

Environment

Parse Android SDK

  • SDK version: 3.0.0
  • Operating system version: API 30

Server

  • Parse Server version: 4.10.4 (I tried in a staging environment with 5.2.0 too)
  • Operating system: Ubuntu 20.04.2 LTS
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): Remote host

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: 4.4.13
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): MongoDB Atlas

Logs

@parse-github-assistant
Copy link

parse-github-assistant bot commented Apr 5, 2022

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@qmetzler-luna
Copy link

After some more testing, the issue seems to happen when updating the lib from 2.1.0 to 3.0.0

@mtrezza
Copy link
Member

mtrezza commented Apr 9, 2022

If you look at the commits, are you able to tell which commit may cause this?

@mtrezza mtrezza added the type:bug Impaired feature or lacking behavior that is likely assumed label Apr 9, 2022
@PLR2388
Copy link
Author

PLR2388 commented Apr 12, 2022

I think the commit that may cause this is this one as the others before 3.0.0 are just renaming or adding documentation 🤔

@azlekov
Copy link
Contributor

azlekov commented Apr 21, 2022

In version 3.0.0 a breaking changes was introduced:

The following deprecated methods are removed: Parse.getParseDir() (use getParseCacheDir(String) or getParseFilesDir(String) instead)

Is very likely that internally the user was saved in the old place and after the upgrade the new one is used where the user cannot be found. If that is correct we can think about implementing a proper migration of the user or/and installation. From what I remember, there was actually some kind of migration, but I need to double-check what covers.

Nice catch @qmetzler-luna

@mtrezza
Copy link
Member

mtrezza commented Apr 21, 2022

@L3K0V if you could verify this, we may retroactively add a warning note to the changelog even before we publish a fix; this could be quite a severe issue if all users who update their app get logged out. I'll at least pin this for now.

@mtrezza mtrezza pinned this issue Apr 21, 2022
@mtrezza mtrezza changed the title ParseUser.getCurrentUser() is null after an update Users are logged out after SDK upgrade Apr 21, 2022
@mman
Copy link

mman commented Apr 25, 2022

I have done quick debugging on this and it is indeed a serious bug.

This commit 7d0faa3#diff-c26dc69a408628b0da844de58b3d793a777cc908e5dde1777e2b54744de5d2bdL131 actually changed where the SDK looks up currentUser, currentInstallation, and installationId files (and maybe others, but these three are that my app uses and I can verify).

Previously these were stored under com.your.app.id/app_Parse/.

Newly they are looked up under com.your.app.id/files/com.parse/.

currentUser

currentInstallation

installationId

The not so trivial fix would be to check whether these files exist at their old locations and move them over to new locations before the SDK has a chance to look them up.

@mtrezza
Copy link
Member

mtrezza commented Apr 25, 2022

I agree that this is a serious bug as it effectively logs out every user. Sounds like a rather trivial fix to me. Would you want to open a PR for this?

@mman
Copy link

mman commented Apr 26, 2022

@mtrezza What's your idea of a trivial fix?

If we just revert back to loading at least currentUser, currentInstallation, and installationId from old location, then all apps out in the wild on 3.0.0 - that were forced to re-login will break as they now contain old data in old location and new data in new location. The old data are potentially/very probably not in sync. And I believe that there was some hidden motivation behind shuffling the files around in the app data directory. Right?

So the fix should be more elaborate, essentially trying to see if the file is present at new location, and use that (assuming login happened on 3.0.0), and if it is not present, trying to move previous file from old location to a new location and use that (assuming user was logged in on 1.x or 2.x).

In any case, looking that 3.0.0 was released Nov 21, it's potentially now out in the wild for several months ideal fix would not break anything again.

Your thoughts?
Martin

@mman
Copy link

mman commented Apr 26, 2022

@mtrezza More over, currentUser is being now loaded from Parse.getParseFilesDir, whereas currentConfig, currentInstallation, and installationId are loaded from ParsePlugins.getFilesDir. They all if I read the code correctly end up in the same location in the end, but any reason why these are not aligned?

thanks,
Martin

@azlekov
Copy link
Contributor

azlekov commented Apr 26, 2022

@mman about

And I believe that there was some hidden motivation behind shuffling the files around in the app data directory. Right?

I did the changes because the old Parse.getParseFilesDir was deprecated for a long time back then. This massive update was the perfect place to introduce some breaking changes. Maybe I missed something to align all of them, because I getting just started with the SDK structure, architecture and decisions.

@mtrezza
Copy link
Member

mtrezza commented Apr 26, 2022

First of all, I'm glad we identified this issue. It actually sounds more like a bug than a breaking change, because there is virtually nothing the developer can do except for writing their own migration routine, which is such an internal matter that it should be done by the SDK.

A trivial fix could be:

if oldPath exists {
  if newPath doesn't exist {
    move all content from old path to new path
  }
  delete old path
}

If someone has both paths already then I wouldn't do any migration and just delete the old path.

In any case, we should add a warning note to the affected versions in the changelog (and GitHub releases page) ASAP, every day more may cause more damage. Anyone wants to open a PR?

@azlekov
Copy link
Contributor

azlekov commented Apr 26, 2022

I will have no availability this and next 2-3 weeks. Sorry. Only have time to follow discussions and doing some reviews if necessary.

@mtrezza
Copy link
Member

mtrezza commented Apr 26, 2022

@L3K0V If you could do a review that would already help a lot.

@mman Would you be up to write a fix? We'll add a bounty to this for urgency so it's compensated as well.

I've added a note to the GH release & changelog:

⚠️ Warning

This version contains a bug that ignores SDK-internal data that is already stored locally on the client side. This includes for example the Parse SDK session token, so an already logged-in user will be required to log in again. If you are not starting with a new app but are considering upgrading an existing app you may want to skip this version and wait for a fix in a future version. (#1158)

Is that description accurate?

@mtrezza mtrezza added the bounty:$50 Bounty applies for fixing this issue (Parse Bounty Program) label Apr 26, 2022
@mman
Copy link

mman commented Apr 27, 2022

@mtrezza I will not be able to look into it in the next few days, perhaps next week depending on what pops up :(

rommansabbir added a commit to rommansabbir/Parse-SDK-Android that referenced this issue May 15, 2022
ParsePlugins ::
- `getCacheDir()`, `getFilesDir()` APIs now has support for backward compatibility before migration to v3.0.0
@mtrezza
Copy link
Member

mtrezza commented May 15, 2022

Thanks to @rommansabbir who submitted the PR for cache migration to fix this issue. Could anyone try out #1168 to verify that it works?

@azlekov
Copy link
Contributor

azlekov commented May 16, 2022

7d0faa3#diff-6cb14853da236c30db3f14e4005ea40c5c45cb8fcb9fc49541693186620de1dcR60

@mtrezza I remember that there was some migration functionality, but for the push notifications. I started wondering if this should be reverted? But I assumed that who is using the 1.26 and early versions which was introduced for a long long time are already migrated. For me this was a very old legacy migration.

Still, similar but very slim and simplified version of such migration should be used to migrate the user, installation etc. I already posted into the PR

@mtrezza
Copy link
Member

mtrezza commented May 16, 2022

Yes, I would remove old migration routines only after a very long time, if they don't hurt being there. Or if we can reasonably assume that the migration should have happened already, because previous SDK versions are not usable anymore (targetSDK version not accepted anymore on Google Play, etc)

@mtrezza
Copy link
Member

mtrezza commented May 19, 2022

Note: conceptual conversation about migration is happening in #1168

@PLR2388
Copy link
Author

PLR2388 commented May 31, 2022

Btw thank you all :)

@mtrezza
Copy link
Member

mtrezza commented May 31, 2022

Thank you for kicking it off by opening the issue ;-)

@mtrezza mtrezza unpinned this issue Jun 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty:$50 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants