{"record":{"id":"7566cac08f8eefd7","repo":"FlowiseAI/Flowise","slug":"failed-to-load-google-sheets-data-error-message","errorCode":null,"errorMessage":"Failed to load Google Sheets data: ${error.message}","messagePattern":"Failed to load Google Sheets data: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/documentloaders/GoogleSheets/GoogleSheets.ts","lineNumber":299,"sourceCode":"                                  omitMetadataKeys\n                              )\n                }))\n            } else {\n                docs = docs.map((doc) => ({\n                    ...doc,\n                    metadata:\n                        _omitMetadataKeys === '*'\n                            ? {}\n                            : omit(\n                                  {\n                                      ...doc.metadata\n                                  },\n                                  omitMetadataKeys\n                              )\n                }))\n            }\n        } catch (error) {\n            throw new Error(`Failed to load Google Sheets data: ${error.message}`)\n        }\n\n        if (output === 'document') {\n            return docs\n        } else {\n            let finaltext = ''\n            for (const doc of docs) {\n                finaltext += `${doc.pageContent}\\n`\n            }\n            return handleEscapeCharacters(finaltext, false)\n        }\n    }\n\n    private async getSpreadsheetMetadata(spreadsheetId: string, accessToken: string): Promise<any> {\n        const url = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}`\n\n        const response = await fetch(url, {\n            headers: {","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/documentloaders/GoogleSheets/GoogleSheets.ts#L281-L317","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Confirm the Google Sheets OAuth credential is linked and the token is fresh (re-authorize the credential node).","Verify the spreadsheetId is the bare ID from the URL, not the whole link, and that the service account/sharing email has Viewer+ access.","If the metadata field is set, ensure it is valid JSON (double-quoted keys/strings) or pass a JS object.","Preserve the cause when re-throwing so stack traces survive: throw new Error('Failed to load Google Sheets data', { cause: error })."],"exampleFix":"// before\nthrow new Error(`Failed to load Google Sheets data: ${error.message}`)\n// after\nthrow new Error(`Failed to load Google Sheets data: ${error instanceof Error ? error.message : String(error)}`, { cause: error })","handlingStrategy":"try-catch","validationCode":"// Pre-flight: validate metadata JSON and required inputs before init()\nfunction validateGoogleSheetsInputs(inputs) {\n  if (inputs.metadata != null) {\n    if (typeof inputs.metadata === 'string') JSON.parse(inputs.metadata) // throws early with a clear message\n    else if (typeof inputs.metadata !== 'object') throw new Error('metadata must be a JSON string or object')\n  }\n  if (!inputs.spreadsheetId) throw new Error('spreadsheetId is required (bare ID, not the full URL)')\n}","typeGuard":null,"tryCatchPattern":"try {\n  await sheetsLoader.init(nodeData, _, options)\n} catch (e) {\n  // the message embeds the real cause; surface it, and read e.cause if chained\n  throw new Error('Google Sheets load failed in pipeline', { cause: e })\n}","preventionTips":["Always link a valid Google Sheets OAuth credential to the loader node.","Pass the bare spreadsheetId, never the full docs.google.com URL.","Validate the metadata field as JSON before runtime.","Re-authorize credentials periodically to avoid stale tokens."],"tags":["google-sheets","oauth","api-wrapper","error-wrapping","metadata"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}