{"record":{"id":"1c84fce4c8fcc332","repo":"Stirling-Tools/Stirling-PDF","slug":"google-drive-is-not-configured","errorCode":null,"errorMessage":"Google Drive is not configured","messagePattern":"Google Drive is not configured","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"frontend/editor/src/core/hooks/useGoogleDrivePicker.ts","lineNumber":65,"sourceCode":"  // Check if Google Drive is configured and reset initialization if disabled\n  useEffect(() => {\n    const configured = isGoogleDriveConfigured(googleDriveBackendConfig);\n    setIsEnabled(configured);\n    // Reset initialization state if Google Drive becomes disabled\n    if (!configured) {\n      setIsInitialized(false);\n    }\n  }, [googleDriveBackendConfig]);\n\n  /**\n   * Initialize the Google Drive service (lazy initialization)\n   */\n  const initializeService = useCallback(async () => {\n    if (isInitialized) return;\n\n    const googleDriveConfig = getGoogleDriveConfig(googleDriveBackendConfig);\n    if (!googleDriveConfig) {\n      throw new Error(\"Google Drive is not configured\");\n    }\n\n    const service = getGoogleDrivePickerService();\n    await service.initialize(googleDriveConfig);\n    setIsInitialized(true);\n  }, [isInitialized, googleDriveBackendConfig]);\n\n  /**\n   * Open the Google Drive picker\n   */\n  const openPicker = useCallback(\n    async (options: UseGoogleDrivePickerOptions = {}): Promise<File[]> => {\n      if (!isEnabled) {\n        setError(\"Google Drive is not configured\");\n        return [];\n      }\n\n      try {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/Stirling-Tools/Stirling-PDF/blob/9ef20dcab80b85041912f045e17a6aea1d08f969/frontend/editor/src/core/hooks/useGoogleDrivePicker.ts#L47-L83","documentation":"Thrown by `initializeService` when `getGoogleDriveConfig(googleDriveBackendConfig)` returns null — i.e. the backend's app-config did not supply a complete Google Drive integration (clientId, apiKey, appId) or googleDriveEnabled is false. The Drive picker cannot be initialized without OAuth/API credentials, so the lazy init refuses.","triggerScenarios":"Backend app-config lacks googleDriveClientId/googleDriveApiKey/googleDriveAppId; googleDriveEnabled is false; the picker was invoked before the config effect (isGoogleDriveConfigured) marked it enabled; a non-Google-Drive build/flavor where config is intentionally absent.","commonSituations":"Self-hosted deployment without Google Drive credentials configured; dev environment without the env vars set; the picker UI was shown despite the backend advertising Drive as disabled.","solutions":["Hide the Google Drive import button when `isEnabled` is false (the hook already tracks it) so initializeService is never called unconfigured.","Configure the backend env (googleDriveClientId, googleDriveApiKey, googleDriveAppId, googleDriveEnabled=true) and reload app-config.","Guard openPicker to call initializeService only when isEnabled, returning [] otherwise.","Show a user-facing 'Google Drive is not configured on this server' message if the action is attempted."],"exampleFix":"// before\nconst googleDriveConfig = getGoogleDriveConfig(googleDriveBackendConfig);\nif (!googleDriveConfig) throw new Error(\"Google Drive is not configured\");\n\n// after — guard at the caller so init is never attempted\nconst openPicker = useCallback(async (options) => {\n  if (!isEnabled) {\n    setError(\"Google Drive is not configured on this server.\");\n    return [];\n  }\n  await initializeService();\n  ...\n}, [isEnabled, initializeService]);","handlingStrategy":"validation","validationCode":"// Only initialize when the backend advertised Drive as configured\nif (!isEnabled) {\n  setError(\"Google Drive is not configured on this server.\");\n  return;\n}\nawait initializeService();","typeGuard":"function isDriveConfigured(cfg: unknown): boolean {\n  return !!cfg && typeof cfg === \"object\" && !!(cfg as { clientId?: string; apiKey?: string }).clientId && !!(cfg as { apiKey?: string }).apiKey;\n}","tryCatchPattern":"try {\n  await openPicker();\n} catch (e) {\n  if (e instanceof Error && e.message === \"Google Drive is not configured\") {\n    setError(\"Google Drive is not configured on this server.\");\n  } else throw e;\n}","preventionTips":["Hide the Google Drive import button when isEnabled is false.","Configure the backend env (googleDriveClientId/ApiKey/AppId, googleDriveEnabled=true) when Drive is needed.","Guard openPicker to call initializeService only when isEnabled."],"tags":["google-drive","config","oauth","integration","validation"],"backgroundTag":null,"analyzedSha":"9ef20dcab80b85041912f045e17a6aea1d08f969","analyzedAt":"2026-08-13T22:11:39.827Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}