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

Brews removed from Google Drive cannot be deleted from "My Brews" page. #2954

Closed
calculuschild opened this issue Jul 26, 2023 · 13 comments · Fixed by #3943
Closed

Brews removed from Google Drive cannot be deleted from "My Brews" page. #2954

calculuschild opened this issue Jul 26, 2023 · 13 comments · Fixed by #3943
Labels
bug We say this works but it doesn't

Comments

@calculuschild
Copy link
Member

calculuschild commented Jul 26, 2023

See https://www.reddit.com/r/homebrewery/comments/158k1z5/brew_with_missing_google_drive_file_cannot_be/?utm_source=share&utm_medium=android_app&utm_name=androidcss&utm_term=1&utm_content=2

Logs seem to show we hit an error trying to retrieve the brew since it doesn't exist, and so we fail out without proceeding to just remove the stub.

@G-Ambatte
Copy link
Collaborator

G-Ambatte commented Jul 26, 2023

This is a strange one... I just went through the process using one of my old brew stored on Google Drive, and everything works as expected, so there must be something strange happening.

deleteBrew specifically looks for a HB 02 error response from getBrew (which can be summed up as getBrew failed with googleError.reason:'notFound') and attempts to delete the stub from the HB MongoDB (HomebrewModel.deleteOne({ editId: id })). We should see in the logs the warning No google brew found for id ${googleId}, the stub with id ${id} will be deleted.

Alternatively, somehow the brew might still be showing up in Google Drive because the information being returned to the UserPage is incorrect - if a file somehow was returning an editId that didn't match it's own file ID? I'm not sure how that could happen but it's possible that the input to the UserPage is incorrect somehow and the

Possible causes:

  • the getBrew is not returning a HB 02 error
  • the deleteOne edit ID is not actually found in the HB database
  • the UserPage is getting incorrect data somehow

@G-Ambatte
Copy link
Collaborator

Inspecting the user-provided link (https://homebrewery.naturalcrit.com/share/1-gwB3caElgqoqwHmQA0guHbD2P56EoBQ1wNbCNj9DJ-D) with the React Component Inspector shows that the returned error definitely has HBErrorCode: "02", which is the expected result. To my mind, this eliminates getBrew as the source of the issue.

@G-Ambatte
Copy link
Collaborator

Without access to the specific edit and share IDs for the file, I can immediately see that the shareID is much longer than a stubbed brew. So either the shareID is coming from Google itself - which would be strange, as the user reports that the brew is already deleted there - or there is a very long share ID in the HB MongoDB somewhere.

@G-Ambatte
Copy link
Collaborator

I was able to reproduce this issue by using Google Drive's permissions settings to set the file access to Restricted, blocking the Service Account. The file was still listed on the User Page, as the listGoogleFiles uses the User auth token.
Attempting to access the file resulted in a 404 / HB02 error, as the getBrew uses the Service Account auth token.
Attempting to delete the file from the User Page resulted in the Share and Edit links becoming very long (as the Mongo stub with the short IDs no longer exists), exactly like the example provided by the user.

@G-Ambatte
Copy link
Collaborator

I believe that we can prevent this issue from re-occurring by modifying the getBrew function to take an auth token parameter, defaulting to the Service Account token, and then having the deleteBrew function pass the User token. This will ensure that the authentication token used throughout the entire process is consistent.

@calculuschild
Copy link
Member Author

calculuschild commented Aug 4, 2023

Have we communicated to the user that we think their brew does exist on their google drive somewhere? My understanding from their post is that the brew is lost and unrecoverable.

We can still fix the deleting issue, but if this is really just due to sharing settings, their brew is still out there somewhere and they probably want it.

@G-Ambatte
Copy link
Collaborator

The following has been posted to Reddit for 11 days now:
https://www.reddit.com/r/homebrewery/comments/158k1z5/brew_with_missing_google_drive_file_cannot_be/jtkzkpu/

I've managed to reproduce this exact situation, in the following conditions:

  • the file still exists somewhere in the linked Google Drive account (even in the Bin)
  • the sharing permissions are set to Restricted, not Anyone with the link can edit

This is because the list of Google files is generated using the user's Google account authentication, but the actual access of the file for viewing, editing, and file deletion is instead performed by the Homebrewery Service Account.

I wonder if there is potential value in also adding a link to the Google file in the Brew item, so there is no opportunity for "I can't find my brew in Google Drive" or "my document is missing!"

@G-Ambatte
Copy link
Collaborator

I wonder if there is potential value in also adding a link to the Google file in the Brew item

PR #2969 is this change, it was a surprisingly simple change to make.

G-Ambatte added a commit to G-Ambatte/homebrewery that referenced this issue Aug 8, 2023
G-Ambatte added a commit to G-Ambatte/homebrewery that referenced this issue Sep 7, 2023
G-Ambatte added a commit to G-Ambatte/homebrewery that referenced this issue Sep 14, 2023
G-Ambatte added a commit to G-Ambatte/homebrewery that referenced this issue Sep 16, 2023
G-Ambatte added a commit to G-Ambatte/homebrewery that referenced this issue Sep 24, 2023
G-Ambatte added a commit to G-Ambatte/homebrewery that referenced this issue Sep 24, 2023
@5e-Cleric 5e-Cleric added the bug We say this works but it doesn't label Oct 4, 2023
G-Ambatte added a commit to G-Ambatte/homebrewery that referenced this issue Jan 13, 2024
G-Ambatte added a commit to G-Ambatte/homebrewery that referenced this issue Jan 16, 2024
@dbolack-ab
Copy link
Collaborator

Was this resolved with the merge?

G-Ambatte added a commit to G-Ambatte/homebrewery that referenced this issue Jan 24, 2024
G-Ambatte added a commit to G-Ambatte/homebrewery that referenced this issue Aug 16, 2024
5e-Cleric added a commit to G-Ambatte/homebrewery that referenced this issue Aug 31, 2024
G-Ambatte added a commit to G-Ambatte/homebrewery that referenced this issue Sep 5, 2024
G-Ambatte added a commit to G-Ambatte/homebrewery that referenced this issue Sep 7, 2024
G-Ambatte added a commit to G-Ambatte/homebrewery that referenced this issue Oct 11, 2024
@G-Ambatte
Copy link
Collaborator

This issue no longer appears to be relevant; I believe it can be closed and PR #2955 can now be closed without merging.

@calculuschild
Copy link
Member Author

I will need to confirm. I had someone ask me about this again recently but it's possible it's something different.

@5e-Cleric
Copy link
Member

5e-Cleric commented Oct 12, 2024

I can confirm the issue still exists, just deleted with my own brew and the stub shows up ad the admin search function:
image

@5e-Cleric
Copy link
Member

But i could delete the brew just now from the user page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug We say this works but it doesn't
Projects
None yet
4 participants