{"record":{"id":"b3b6f4914be344c0","repo":"ToolJet/ToolJet","slug":"missing-required-fields-in-sourceoptions-b3b6f4","errorCode":null,"errorMessage":"Missing required fields in sourceOptions","messagePattern":"Missing required fields in sourceOptions","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/packages/common/lib/oauth.ts","lineNumber":178,"sourceCode":"  } catch (error) {\n    throw new QueryError('Failed to fetch access token', {}, {});\n  }\n}\n\nfunction handleAuthorizationCodeGrant(sourceOptions: any, additionalOptions?: any): QueryResult {\n  return {\n    status: 'needs_oauth',\n    data: { auth_url: getAuthUrl(sourceOptions, additionalOptions) },\n  };\n}\n\nasync function getTokenForClientCredentialsGrant(sourceOptions: any) {\n  if (\n    isEmpty(sourceOptions.access_token_url) ||\n    isEmpty(sourceOptions.client_id) ||\n    isEmpty(sourceOptions.client_secret)\n  ) {\n    throw new Error('Missing required fields in sourceOptions');\n  }\n\n  // SSRF Protection: Validate access token URL\n  await validateUrlForSSRF(sourceOptions.access_token_url);\n\n  const headersObject = sanitizeParams(sourceOptions.access_token_custom_headers);\n  const clientAuth = sourceOptions.client_auth?.toLowerCase();\n\n  try {\n    const baseRequestBody = {\n      grant_type: sourceOptions.grant_type || 'client_credentials',\n      ...(sourceOptions.audience ? { audience: sourceOptions.audience } : {}),\n      ...(sourceOptions.scopes ? { scope: sourceOptions.scopes } : {}),\n    };\n\n    const headers = {\n      'Content-Type': 'application/x-www-form-urlencoded',\n      ...(Object.keys(headersObject).length > 0 && headersObject),","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/ToolJet/ToolJet/blob/20602a8e101f2e59686c9afde0d1402aac2c8871/plugins/packages/common/lib/oauth.ts#L160-L196","documentation":"Error \"Missing required fields in sourceOptions\" thrown in ToolJet/ToolJet.","triggerScenarios":"Token refresh is attempted when sourceOptions lack required fields (client id, secret, or redirect URI).","commonSituations":"Defend by validating all required sourceOptions fields before initiating the OAuth flow.","solutions":["Provide access_token_url, client_id, and client_secret in sourceOptions.","Check for empty strings or wrong option keys."],"exampleFix":"Fill access_token_url, client_id, and client_secret in the data source OAuth config.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"20602a8e101f2e59686c9afde0d1402aac2c8871","analyzedAt":"2026-08-13T05:58:54.221Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}