Stirling-Tools/Stirling-PDF · warning · Error

Google Drive is not configured

Error message

Google Drive is not configured

What it means

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.

Source

Thrown at frontend/editor/src/core/hooks/useGoogleDrivePicker.ts:65

  // Check if Google Drive is configured and reset initialization if disabled
  useEffect(() => {
    const configured = isGoogleDriveConfigured(googleDriveBackendConfig);
    setIsEnabled(configured);
    // Reset initialization state if Google Drive becomes disabled
    if (!configured) {
      setIsInitialized(false);
    }
  }, [googleDriveBackendConfig]);

  /**
   * Initialize the Google Drive service (lazy initialization)
   */
  const initializeService = useCallback(async () => {
    if (isInitialized) return;

    const googleDriveConfig = getGoogleDriveConfig(googleDriveBackendConfig);
    if (!googleDriveConfig) {
      throw new Error("Google Drive is not configured");
    }

    const service = getGoogleDrivePickerService();
    await service.initialize(googleDriveConfig);
    setIsInitialized(true);
  }, [isInitialized, googleDriveBackendConfig]);

  /**
   * Open the Google Drive picker
   */
  const openPicker = useCallback(
    async (options: UseGoogleDrivePickerOptions = {}): Promise<File[]> => {
      if (!isEnabled) {
        setError("Google Drive is not configured");
        return [];
      }

      try {

View on GitHub (pinned to 9ef20dcab8)

Solutions

  1. Hide the Google Drive import button when `isEnabled` is false (the hook already tracks it) so initializeService is never called unconfigured.
  2. Configure the backend env (googleDriveClientId, googleDriveApiKey, googleDriveAppId, googleDriveEnabled=true) and reload app-config.
  3. Guard openPicker to call initializeService only when isEnabled, returning [] otherwise.
  4. Show a user-facing 'Google Drive is not configured on this server' message if the action is attempted.

Example fix

// before
const googleDriveConfig = getGoogleDriveConfig(googleDriveBackendConfig);
if (!googleDriveConfig) throw new Error("Google Drive is not configured");

// after — guard at the caller so init is never attempted
const openPicker = useCallback(async (options) => {
  if (!isEnabled) {
    setError("Google Drive is not configured on this server.");
    return [];
  }
  await initializeService();
  ...
}, [isEnabled, initializeService]);
Defensive patterns

Strategy: validation

Validate before calling

// Only initialize when the backend advertised Drive as configured
if (!isEnabled) {
  setError("Google Drive is not configured on this server.");
  return;
}
await initializeService();

Type guard

function isDriveConfigured(cfg: unknown): boolean {
  return !!cfg && typeof cfg === "object" && !!(cfg as { clientId?: string; apiKey?: string }).clientId && !!(cfg as { apiKey?: string }).apiKey;
}

Try / catch

try {
  await openPicker();
} catch (e) {
  if (e instanceof Error && e.message === "Google Drive is not configured") {
    setError("Google Drive is not configured on this server.");
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Stirling-Tools/Stirling-PDF@9ef20dcab8 (2026-08-13). Data as JSON: /api/errors/1c84fce4c8fcc332. Report an issue: GitHub.