Search code examples
google-apps-scriptgoogle-workspace

DriveApp.setSharing is now throwing an Exception, is there something wrong with the legacy runtime?


The following code was working previously (and still works with the V8 runtime):

function myFunction() {
  var file = DriveApp.createFile("Test", "Test");
  file.setSharing(DriveApp.Access.DOMAIN_WITH_LINK, DriveApp.Permission.VIEW);
  Logger.log(file.getUrl());
}

Now it is throwing the following error:

Invalid argument

I have isolated the issue down to the DOMAIN or DOMAIN_WITH_LINK Access parameter. PRIVATE works fine. ANYONE and ANYONE_WITH_LINK throws a permissions error (which is expected as this user does not have access to share outside the domain).

Unfortunately I cannot update the script to use the V8 runtime due to my use case.

One other thing to note: I get this exact same error with this exact same code when running it in a free Google account. (Could it be an issue with Google's engine recognizing the domain?)


Solution

  • As mentioned by @Cooper there are many issues regarding sharing.

    The most recent issue is currently being worked on: https://issuetracker.google.com/issues/161201634

    You just have to go there and click on the star next to the title so you get updates on the issue and you give the issue more visibility.