paperclipai/paperclip · error · Error

endIndex must be greater than startIndex.

Error message

endIndex must be greater than startIndex.

What it means

The delete_rows tool validates its inputs against the deleteRowsSchema and additionally enforces the invariant endIndex > startIndex before delegating to client.deleteRows. This guards the Google Sheets batchClear/deleteDimension metadata API from a no-op or inverted range.

Source

Thrown at packages/google-sheets-mcp-server/src/tools.ts:242

      "clear_values",
      "Clear values in an allowlisted spreadsheet range.",
      "destructive",
      readValuesSchema,
      async ({ spreadsheetId, range }) => {
        assertAllowed(allowedSpreadsheetIdSet, spreadsheetId);
        return options.client.clearValues(spreadsheetId, range);
      },
    ),
    makeTool(
      options,
      "delete_rows",
      "Delete rows from an allowlisted spreadsheet tab.",
      "destructive",
      deleteRowsSchema,
      async (input) => {
        assertAllowed(allowedSpreadsheetIdSet, input.spreadsheetId);
        if (input.endIndex <= input.startIndex) {
          throw new Error("endIndex must be greater than startIndex.");
        }
        return options.client.deleteRows(input);
      },
    ),
  ];
}

View on GitHub (pinned to 67001ec6eb)

Solutions

  1. Re-check that endIndex is strictly greater than startIndex using the API's 0-based exclusive-end convention.
  2. Swap the two values if they were passed in the wrong order.
  3. Add a client-side assert before invoking the tool.

Example fix

// before
{ spreadsheetId, tabId, startIndex: 10, endIndex: 10 }  // -> error
// after
{ spreadsheetId, tabId, startIndex: 10, endIndex: 11 }
Defensive patterns

Strategy: validation

Validate before calling

function validRowRange(startIndex: number, endIndex: number): boolean {
  return Number.isInteger(startIndex) && Number.isInteger(endIndex) && endIndex > startIndex;
}
if (!validRowRange(input.startIndex, input.endIndex)) throw new Error('startIndex must be a non-negative integer less than endIndex');

Prevention

When it happens

Trigger: A tools/call to delete_rows with endIndex <= startIndex — either equal (zero-width range) or reversed (endIndex less than startIndex). Most often a 0-based vs 1-based indexing mistake or an off-by-one when computing the last row.

Common situations: Caller uses inclusive end where the API expects exclusive end; agent computes endIndex from a row count and forgets to add the offset; swapped argument order.

Related errors


AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12). Data as JSON: /api/errors/db85133d0a6f9662. Report an issue: GitHub.