FlowiseAI/Flowise · error · Error

Failed to load Google Sheets data: ${error.message}

Error message

Failed to load Google Sheets data: ${error.message}

What it means

Top-level catch-all thrown by the Google Sheets document loader's init() when any step of the loading flow throws. It interpolates the underlying error's .message verbatim, so the original stack trace and error class are lost (no `cause` chaining). The wrapped error most often originates from the private getSpreadsheetMetadata/getSheetData HTTP helpers, the credential token lookup, or a JSON.parse on the metadata input field.

Source

Thrown at packages/components/nodes/documentloaders/GoogleSheets/GoogleSheets.ts:299

                                  omitMetadataKeys
                              )
                }))
            } else {
                docs = docs.map((doc) => ({
                    ...doc,
                    metadata:
                        _omitMetadataKeys === '*'
                            ? {}
                            : omit(
                                  {
                                      ...doc.metadata
                                  },
                                  omitMetadataKeys
                              )
                }))
            }
        } catch (error) {
            throw new Error(`Failed to load Google Sheets data: ${error.message}`)
        }

        if (output === 'document') {
            return docs
        } else {
            let finaltext = ''
            for (const doc of docs) {
                finaltext += `${doc.pageContent}\n`
            }
            return handleEscapeCharacters(finaltext, false)
        }
    }

    private async getSpreadsheetMetadata(spreadsheetId: string, accessToken: string): Promise<any> {
        const url = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}`

        const response = await fetch(url, {
            headers: {

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Read the inner ${error.message} — it names the real failing step (e.g. 'Failed to get spreadsheet metadata: 403 Forbidden') and points to the true cause.
  2. Confirm the Google Sheets OAuth credential is linked and the token is fresh (re-authorize the credential node).
  3. Verify the spreadsheetId is the bare ID from the URL, not the whole link, and that the service account/sharing email has Viewer+ access.
  4. If the metadata field is set, ensure it is valid JSON (double-quoted keys/strings) or pass a JS object.
  5. Preserve the cause when re-throwing so stack traces survive: throw new Error('Failed to load Google Sheets data', { cause: error }).

Example fix

// before
throw new Error(`Failed to load Google Sheets data: ${error.message}`)
// after
throw new Error(`Failed to load Google Sheets data: ${error instanceof Error ? error.message : String(error)}`, { cause: error })
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight: validate metadata JSON and required inputs before init()
function validateGoogleSheetsInputs(inputs) {
  if (inputs.metadata != null) {
    if (typeof inputs.metadata === 'string') JSON.parse(inputs.metadata) // throws early with a clear message
    else if (typeof inputs.metadata !== 'object') throw new Error('metadata must be a JSON string or object')
  }
  if (!inputs.spreadsheetId) throw new Error('spreadsheetId is required (bare ID, not the full URL)')
}

Try / catch

try {
  await sheetsLoader.init(nodeData, _, options)
} catch (e) {
  // the message embeds the real cause; surface it, and read e.cause if chained
  throw new Error('Google Sheets load failed in pipeline', { cause: e })
}

Prevention

When it happens

Trigger: Any exception inside the try block at GoogleSheets.ts:255-298: OAuth access token missing/expired, getSpreadsheetMetadata returning non-ok, getSheetData returning non-ok, spreadsheetId not shared with the service account, JSON.parse(metadata) throwing on a non-object string, or textSplitter.splitDocuments rejecting.

Common situations: Credential node not linked to the loader so getCredentialParam returns empty; user pastes the full Google Sheets URL into a field expecting only the spreadsheetId; metadata field contains malformed JSON like {url: x} (unquoted keys); Sheets API daily quota/quota-per-100-seconds exceeded during a bulk ingest.

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/7566cac08f8eefd7. Report an issue: GitHub.