google sheets – weird bug(?) with getValue returning “You are trying to edit a protected cell or object”


This is just…bizarre…

I’m running a function with a user that does have full Edit access to the Sheets in question.

This code:

function test() {
  
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName('importDailyOrders');
  
  var column = sheet.getRange("A1:A");
  // Plain text
  column.setNumberFormat("@");
 
  var sheet = ss.getSheetByName('orderSummary');
  var data = sheet.getRange("A2").getValue();
}

…gives me this error

Exception: You are trying to edit a protected cell or object. Please contact the spreadsheet owner to remove protection if you need to edit. (line 11, file …

But commenting out the setNumberFormat allows the function to run.

Note that the code works fine for the Sheet owner. This error only happens when running the script by a different user.

Is this a bug? If not…what’s happening?