instructure/canvas-lms · error · GoogleDrive::ConnectionException

GoogleDrive is not configured

Error message

GoogleDrive is not configured

What it means

GoogleDrive::Connection#drive builds the memoized Google Drive API client, but only when global GoogleDrive config (a Proc set via Connection.config=) exists. If GoogleDrive::Connection.config is nil — the integration was never configured at boot — it raises ConnectionException before touching tokens or the API.

Solutions

  1. Provide config/google_drive.yml (client_id, client_secret, redirect_uri, etc.) so GoogleDrive::Connection.config gets set at boot
  2. Restart the app after adding the config so initializers populate Connection.config
  3. Verify the config file parses and contains the expected keys before deploying
  4. Guard usage: check GoogleDrive::Connection.config before calling drive and surface a friendly 'not configured' message

Example fix

// before
docs = GoogleDrive::Connection.new(refresh_token, user).list
// after
if GoogleDrive::Connection.config.nil?
  docs = []
else
  docs = GoogleDrive::Connection.new(refresh_token, user).list
end
Defensive patterns

Strategy: type-guard

Validate before calling

raise 'GoogleDrive not configured' if GoogleDrive::Connection.config.nil?

Type guard

def google_drive_ready?
  !GoogleDrive::Connection.config.nil?
end

Try / catch

begin
  conn.drive
rescue ConnectionException => e
  raise unless e.message.include?('not configured')
  Rails.logger.error('Add config/google_drive.yml')
end

Prevention

When it happens

Trigger: Calling drive (directly or via file/folder methods) on a Canvas instance where the google_drive config Proc was never set (e.g. config/google_drive.yml missing or empty so Connection.config was never assigned).

Common situations: Environment without the Google Drive config file; config file present but blank/invalid so initialization skipped; using Google Drive features on a node where config loading failed.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/477a673ab23a3257. Report an issue: GitHub.

Appendix: source

Thrown at gems/google_drive/lib/google_drive/connection.rb:137

      @config.call
    end

    private

    def exception_message(exception)
      return "Google Drive connection timed out" if exception.cause.is_a?(Faraday::TimeoutError)

      JSON.parse(exception.body).dig("error", "message")
    rescue JSON::ParserError, TypeError
      exception.message
    end

    def normalize_document_id(doc_id)
      doc_id.gsub(/^.+:/, "")
    end

    def drive
      raise ConnectionException, "GoogleDrive is not configured" if GoogleDrive::Connection.config.nil?
      raise NoTokenError unless @refresh_token && @access_token

      @drive ||= GoogleDrive::Client.create(GoogleDrive::Connection.config, @refresh_token, @access_token).tap do |drive|
        drive.client_options.open_timeout_sec =
          drive.client_options.send_timeout_sec =
            drive.client_options.read_timeout_sec = @timeout
        drive.request_options.retries = @retries
      end
    end
  end
end

View on GitHub (pinned to 1c9f0bb801)