{"record":{"id":"204c8958e7d311a5","repo":"ToolJet/ToolJet","slug":"spreadsheet-title-is-required","errorCode":null,"errorMessage":"Spreadsheet title is required","messagePattern":"Spreadsheet title is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/packages/googlesheets/lib/operations.ts","lineNumber":64,"sourceCode":"\nasync function makeRequestToListAllSheets(spreadsheet_id: string, authHeader: any): Promise<SpreadsheetResponseBody> {\n  const url = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheet_id}`;\n\n  return await got.get(url, { headers: authHeader }).json();\n}\n\nexport async function listAllSheets(spreadsheet_id: string, authHeader: any): Promise<SpreadsheetResponseBody> {\n  try {\n    const response = await makeRequestToListAllSheets(spreadsheet_id, authHeader);\n    return { sheets: response.sheets };\n  } catch (error) {\n    throw new Error(`Error fetching all sheets: ${error.response?.statusCode || ''} ${error.message}`);\n  }\n}\n\nexport async function createSpreadSheet(title: string, authHeader: any) {\n  if (!title) {\n    throw new Error('Spreadsheet title is required');\n  }\n  const requestBody = {\n    properties: {\n      title: title,\n    },\n  };\n\n  try {\n    const response = await makeRequestToCreateSpreadsheet(requestBody, authHeader);\n    return { spreadsheetId: response.spreadsheetId };\n  } catch (error) {\n    throw new Error(`Error creating spreadsheet: ${error.response?.statusCode || ''} ${error.message}`);\n  }\n}\n\nexport async function batchUpdateToSheet(\n  spreadSheetId: string,\n  spreadsheetRange = 'A1:Z500',","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/ToolJet/ToolJet/blob/20602a8e101f2e59686c9afde0d1402aac2c8871/plugins/packages/googlesheets/lib/operations.ts#L46-L82","documentation":"Thrown by createSpreadSheet() in the v1 googlesheets plugin when the title argument is falsy. The guard rejects empty/undefined titles before any HTTP call to the Google Sheets API, because a spreadsheet cannot be created without a name. Note the check is a loose truthiness test (`!title`), so a whitespace-only string like ' ' passes the guard but produces a poorly-named spreadsheet.","triggerScenarios":"Calling createSpreadsheet with an empty string, undefined, null, or 0 as the title. Commonly the title is bound from a ToolJet UI text input that the user left blank.","commonSituations":"A form field for the spreadsheet title is not filled; the bound component returns an empty string by default; a downstream transform strips the value to '' before the call.","solutions":["Trim and validate the title before calling createSpreadSheet: reject empty and whitespace-only strings client-side.","Provide a sensible default name (e.g. timestamped) when the user leaves the field blank.","Surface a required-field error in the UI so the call is never made with a missing title."],"exampleFix":"// before\nawait createSpreadSheet(titleInput.value, authHeader);\n\n// after\nconst title = (titleInput.value || '').trim();\nif (!title) throw new Error('Title cannot be empty');\nawait createSpreadSheet(title, authHeader);","handlingStrategy":"validation","validationCode":"function assertCreateTitle(title: unknown): asserts title is string {\n  if (typeof title !== 'string' || title.trim().length === 0) {\n    throw new Error('Spreadsheet title is required');\n  }\n}\nassertCreateTitle(title); // before createSpreadSheet(title, authHeader)","typeGuard":"const isValidTitle = (t: unknown): t is string =>\n  typeof t === 'string' && t.trim().length > 0;","tryCatchPattern":"try { await createSpreadSheet(title, authHeader); }\ncatch (e) {\n  if (/title is required/i.test(e.message)) ui.warn('Please enter a spreadsheet title');\n  else throw e;\n}","preventionTips":["Trim and validate the title in the UI before enabling the submit button.","Bind the title field as required in the ToolJet component so it cannot be empty.","Note the guard is truthiness-based; whitespace-only titles slip through - validate trimmed length."],"tags":["input-validation","google-sheets","required-field","typescript"],"backgroundTag":null,"analyzedSha":"20602a8e101f2e59686c9afde0d1402aac2c8871","analyzedAt":"2026-08-13T05:58:54.221Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}