Skip to content

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.

Coverage Every rule myFunction checks, with flagged and corrected examples See the rules
Required values D-001

Missing required GmailApp arguments

Catch an incomplete GmailApp.createDraft call before you run the script.

Read the diagnostic

Literal validation D-002

Invalid email recipient

Find the malformed address inside a comma-separated MailApp recipient list.

Read the diagnostic

Performance D-003

Service call inside a loop

Replace repeated Spreadsheet service calls with one batched range read.

Read the diagnostic

Type errors D-004

TypeError: X is not a function

Tell a misspelled method from a method called on the wrong Apps Script class.

Read the diagnostic

Null and undefined D-005

Cannot read properties of null (reading 'getRange')

Find the unchecked getSheetByName or getActive lookup behind the crash.

Read the diagnostic

Type errors D-006

TypeError: e.range is not a function

Stop calling the onEdit event property as though it were a method.

Read the diagnostic

Null and undefined D-007

Cannot read properties of undefined (reading 'setDataValidation')

Trace the undefined range back to a bad index or a lookup that missed.

Read the diagnostic

Range shape D-008

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

Range shape D-009

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

Range shape D-010

The coordinates or dimensions of the range are invalid

Catch the zero-length or zero-based range before getRange runs.

Read the diagnostic

Type errors D-011

ReferenceError: X is not defined

Separate a typo from a scope gap or a cross-file load-order problem.

Read the diagnostic

Type errors D-012

ReferenceError: GoogleAppsScript is not defined

Keep the TypeScript type namespace out of runtime code.

Read the diagnostic

Syntax D-013

Missing ) after argument list

Find the unclosed parenthesis above the line the parser reports.

Read the diagnostic

Syntax D-014

Unterminated string literal

Spot the smart quote or missing quote breaking the line.

Read the diagnostic

Data D-015

JSON.parse errors in Apps Script

Check for an empty or non-JSON response body before parsing it.

Read the diagnostic

Menus and triggers D-016

Script function not found

Point a menu item or installable trigger at a function that exists.

Read the diagnostic

HTML Service D-017

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.