googleapis/mcp-toolbox · error

error fetching connections: %w

Error message

error fetching connections: %w

What it means

The looker-health-pulse tool wraps Looker SDK errors while listing all database connections via AllConnections. This library throws it whenever the Looker API call to enumerate connections fails, preserving the underlying reason (auth, network, permissions) via %w wrapping. It is the first step of the health pulse run, so a failure here aborts the whole pulse before any checks execute.

Source

Thrown at internal/tools/looker/lookerhealthpulse/lookerhealthpulse.go:223

// Check DB connections and run tests
func (t *pulseTool) checkDBConnections(ctx context.Context, source compatibleSource) (interface{}, error) {
	logger, err := util.LoggerFromContext(ctx)
	if err != nil {
		return nil, fmt.Errorf("unable to get logger from ctx: %s", err)
	}
	logger.InfoContext(ctx, "Test 1/6: Checking connections")

	reservedNames := map[string]struct{}{
		"looker__internal__analytics__replica": {},
		"looker__internal__analytics":          {},
		"looker":                               {},
		"looker__ilooker":                      {},
	}

	connections, err := t.SdkClient.AllConnections("", source.LookerApiSettings())
	if err != nil {
		return nil, fmt.Errorf("error fetching connections: %w", err)
	}

	var filteredConnections []v4.DBConnection
	for _, c := range connections {
		if _, reserved := reservedNames[*c.Name]; !reserved {
			filteredConnections = append(filteredConnections, c)
		}
	}
	if len(filteredConnections) == 0 {
		return nil, fmt.Errorf("no connections found")
	}

	var results []map[string]interface{}
	for _, conn := range filteredConnections {
		var errors []string
		// Test connection (simulate test_connection endpoint)
		resp, err := t.SdkClient.TestConnection(*conn.Name, nil, source.LookerApiSettings())
		if err != nil {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Verify the looker source credentials (base URL, client_id, client_secret) and test connectivity with curl to the Looker /connections API endpoint
  2. Check the wrapped error message (%w) for the root cause — 401/403 means fix credentials/permissions, timeout/DNS means fix network
  3. Ensure the API user has admin or at least view_connections permissions on the Looker instance
  4. If running on Looker (Google Cloud core), confirm the connections listing API is supported for your instance type

Example fix

// before: opaque failure
connections, err := t.SdkClient.AllConnections("", source.LookerApiSettings())
if err != nil {
	return nil, fmt.Errorf("error fetching connections: %w", err)
}
// after: pre-validate client reachability
if _, err := t.SdkClient.Me(source.LookerApiSettings()); err != nil {
	return nil, fmt.Errorf("looker API unreachable or unauthorized: %w", err)
}
connections, err := t.SdkClient.AllConnections("", source.LookerApiSettings())
if err != nil {
	return nil, fmt.Errorf("error fetching connections: %w", err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Go: verify Looker API connectivity before running the pulse
if _, err := sdkClient.Me(settings); err != nil {
	return fmt.Errorf("looker API unavailable: %w", err)
}

Try / catch

connections, err := t.SdkClient.AllConnections("", settings)
if err != nil {
	var apiErr *looker.GenericOpenAPIError
	if errors.As(err, &apiErr) {
		log.Printf("looker API error: %s", apiErr.Body())
	}
	return fmt.Errorf("error fetching connections: %w", err)
}

Prevention

When it happens

Trigger: t.SdkClient.AllConnections("", source.LookerApiSettings()) returns an error: invalid/expired Looker API credentials, network failure to the Looker instance, insufficient permissions for the API user, or the Looker instance being unreachable.

Common situations: Misconfigured client_id/client_secret on the looker source; Looker instance URL typo or firewall blocking egress; API user lacking permission to view connections; Looker (Google Cloud core) instances where connection management APIs differ; expired OAuth tokens.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/67c064af7a8a0774. Report an issue: GitHub.