Diagnostic reference
Apps Script errors and how to fix them
Plain-language explanations of common Google Apps Script errors and the diagnostics myFunction reports, each with the code before and after the fix.
Missing required GmailApp arguments
Catch an incomplete GmailApp.createDraft call before you run the script.
Read the diagnostic
Invalid email recipient
Find the malformed address inside a comma-separated MailApp recipient list.
Read the diagnostic
Service call inside a loop
Replace repeated Spreadsheet service calls with one batched range read.
Read the diagnostic
TypeError: X is not a function
Tell a misspelled method from a method called on the wrong Apps Script class.
Read the diagnostic
Cannot read properties of null (reading 'getRange')
Find the unchecked getSheetByName or getActive lookup behind the crash.
Read the diagnostic
TypeError: e.range is not a function
Stop calling the onEdit event property as though it were a method.
Read the diagnostic
Cannot read properties of undefined (reading 'setDataValidation')
Trace the undefined range back to a bad index or a lookup that missed.
Read the diagnostic
The number of columns in the data does not match the number of columns in the range
Find the ragged row breaking a setValues write.
Read the diagnostic
The number of rows in the data does not match the number of rows in the range
Size the target range from the array instead of a separate row count.
Read the diagnostic
The coordinates or dimensions of the range are invalid
Catch the zero-length or zero-based range before getRange runs.
Read the diagnostic
ReferenceError: X is not defined
Separate a typo from a scope gap or a cross-file load-order problem.
Read the diagnostic
ReferenceError: GoogleAppsScript is not defined
Keep the TypeScript type namespace out of runtime code.
Read the diagnostic
Missing ) after argument list
Find the unclosed parenthesis above the line the parser reports.
Read the diagnostic
Unterminated string literal
Spot the smart quote or missing quote breaking the line.
Read the diagnostic
JSON.parse errors in Apps Script
Check for an empty or non-JSON response body before parsing it.
Read the diagnostic
Script function not found
Point a menu item or installable trigger at a function that exists.
Read the diagnostic
No HTML file named X was found
Match the name passed to HtmlService to a file in the project.
Read the diagnostic
Quick fixes
Quick fixes apply only when you choose them.
myFunction checks the code open in the Apps Script editor and reports the problems it supports. A rule-based quick fix changes that editor text only after you choose it. An AI quick fix shows a diff before it changes code.