taers232c / GAMADV-XTD3

Command line tool to manage Google Workspace
714 stars 87 forks source link

[BUG] Unable to move file to shared drive #263

Closed jay-eleven closed 2 years ago

jay-eleven commented 2 years ago

Hi Ross!!

I've noticed that moving a file to a shared drive suddenly stopped working raising a trap:

User: jay@d.com, Move 1 Drive File/Folder
Traceback (most recent call last):
  File "__init__.py", line 49204, in moveDriveFile
AttributeError: module 'gamlib.glgapi' has no attribute 'FILE_OWNER_NOT_MEMBER_OF_SHAREDDRIVE'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "__init__.py", line 62013, in ProcessGAMCommand
  File "__init__.py", line 49218, in moveDriveFile
AttributeError: module 'gamlib.glgapi' has no attribute 'fileOwnerNotMemberOfSharedDrive'

Steps to reproduce:

  1. Create a file in My Drive:
    gam user jay create drivefile drivefilename "Test file"
    User: jay@d.com, Drive File: Test file(file_id), Created
  2. Check file permissions:
    gam user jay show drivefileacl drivefile file_id fields role
    User: jay@d.com, Show 1 Drive File/Folder
    Drive File/Folder ID: file_id, Show 1 Permittee
    Permission
      role: owner
  3. Create a shared drive:
    gam user jay create teamdrive TEST_TEAMDRIVE
    User: jay@d.com, Shared Drive Name: TEST_TEAMDRIVE, Shared Drive ID: drive_id, Created
  4. Check shared drive permissions:
    gam user jay show drivefileacl teamdrive drive_id fields role
    User: jay@d.com, Show 1 Drive File/Folder
    Drive File/Folder ID: drive_id, Show 1 Permittee
    Permission
      role: organizer
  5. Move file to shared drive:
    
    gam user jay move drivefile file_id teamdriveparent "TEST_TEAMDRIVE"
    User: jay@d.com, Move 1 Drive File/Folder
    Traceback (most recent call last):
    File "__init__.py", line 49204, in moveDriveFile
    AttributeError: module 'gamlib.glgapi' has no attribute 'FILE_OWNER_NOT_MEMBER_OF_SHAREDDRIVE'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "init.py", line 62013, in ProcessGAMCommand File "init.py", line 49218, in moveDriveFile AttributeError: module 'gamlib.glgapi' has no attribute 'fileOwnerNotMemberOfSharedDrive'


User jay is file owner and shared drive organizer so this should work?
taers232c commented 2 years ago

Traps fixed in 6.20.08. Rerun test.

taers232c commented 2 years ago
$ gam user testsimple create drivefile drivefilename "Test file"
User: testsimple@domain.com, Drive File: Test file(1L_ZOtXxXkqXO-3qOeSNcuK0lAyQ-Wxyz), Created

$ gam user testsimple create teamdrive TEST_TEAMDRIVE
User: testsimple@domain.com, Shared Drive Name: TEST_TEAMDRIVE, Shared Drive ID: 0ANI3g0zpB8wHUk0XYZ, Created

$ gam user testsimple show drivefileacl teamdriveid 0ANI3g0zpB8wHUk0XYZ fields role
User: testsimple@domain.com, Show 1 Drive File/Folder
  Drive File/Folder ID: 0ANI3g0zpB8wHUk0XYZ, Show 1 Permittee
    Permission
      role: organizer

$ gam user testsimple move drivefile 1L_ZOtXxXkqXO-3qOeSNcuK0lAyQ-Wxyz  teamdriveparent "TEST_TEAMDRIVE"
User: testsimple@domain.com, Move 1 Drive File/Folder
  User: testsimple@domain.com, Drive File: Test file, Moved to: Test file, Drive Folder ID: 0ANI3g0zpB8wHUk0XYZ
taers232c commented 2 years ago

Does user jay have the following role: Team Drive Admin Ability to move folders to team drives

jay-eleven commented 2 years ago
jay@cloudshell:~$ gam show admins user jay 
Show 4 Role Assignment IDs
  Role Assignment ID: 4409958334464080 (1/4)
    roleId: 4409958334464001
    role: _SEED_ADMIN_ROLE
....

User jay is Super Admin

jay@cloudshell:~$ ./updategam.sh
jay@cloudshell:~$ gam user jay move drivefile name "Test file" teamdriveparent "TEST_TEAMDRIVE"
Getting all Drive Files/Folders that match query ('me' in owners and name = 'Test file') for jay@d.com
Got 1 Drive File/Folder that matched query ('me' in owners and name = 'Test file') for jay@d.com...
User: jay@d.com, Move 1 Drive File/Folder
  User: jay@d.com, Drive File: Test file, Moved to: Test file, Drive Folder ID: 0AC0mjAOeVVffUk9PVA

Works!

Thanks Ross!