googleapis/mcp-toolbox · error

error fetching LookML models: %w

Error message

error fetching LookML models: %w

What it means

vacuumTool.models calls the Looker SDK's AllLookmlModels(v4.RequestAllLookmlModels{}, nil) to list all LookML models for the connected instance. Any SDK-level failure (network error, auth rejection, API error response) is wrapped as "error fetching LookML models: %w" and aborts the models vacuum step. The root cause is always contained in the wrapped %w error.

Source

Thrown at internal/tools/looker/lookerhealthvacuum/lookerhealthvacuum.go:218

	timeframe  int
	minQueries int
}

func (t *vacuumTool) models(ctx context.Context, project, model string) ([]map[string]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, "Vacuuming models...")

	usedModels, err := t.getUsedModels(ctx)
	if err != nil {
		return nil, err
	}

	lookmlModels, err := t.SdkClient.AllLookmlModels(v4.RequestAllLookmlModels{}, nil)
	if err != nil {
		return nil, fmt.Errorf("error fetching LookML models: %w", err)
	}

	var results []map[string]interface{}
	for _, m := range lookmlModels {
		if (project == "" || (m.ProjectName != nil && *m.ProjectName == project)) &&
			(model == "" || (m.Name != nil && *m.Name == model)) {

			queryCount := 0
			if qc, ok := usedModels[*m.Name]; ok {
				queryCount = qc
			}

			unusedExplores, err := t.getUnusedExplores(ctx, *m.Name)
			if err != nil {
				return nil, err
			}

			results = append(results, map[string]interface{}{

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Unwrap and inspect the wrapped error to identify the HTTP status or transport failure.
  2. Verify looker source config: base_url and client credentials are correct and the instance is reachable (curl the /login endpoint).
  3. Confirm the API user has permissions to list LookML models.
  4. Retry on 429/5xx after backing off; check Looker instance health.

Example fix

// before — no diagnostics
lookmlModels, err := t.SdkClient.AllLookmlModels(v4.RequestAllLookmlModels{}, nil)

// after — check connectivity/credentials before retry
lookmlModels, err := t.SdkClient.AllLookmlModels(v4.RequestAllLookmlModels{}, nil)
if err != nil {
    logger.ErrorContext(ctx, "AllLookmlModels failed", "err", err)
    return nil, fmt.Errorf("error fetching LookML models: %w", err)
}
Defensive patterns

Strategy: retry

Validate before calling

// pre-flight check before vacuuming
resp, err := http.Get(strings.TrimSuffix(baseURL, "/") + "/login")
if err != nil || resp.StatusCode >= 500 {
    return fmt.Errorf("looker instance unreachable: %v", err)
}

Try / catch

lookmlModels, err := sdk.AllLookmlModels(v4.RequestAllLookmlModels{}, nil)
var apiErr *lookersdk.APIError
if errors.As(err, &apiErr) && (apiErr.Is429() || apiErr.Response.StatusCode >= 500) {
    // retry with exponential backoff
}
if err != nil {
    return fmt.Errorf("error fetching LookML models: %w", err)
}

Prevention

When it happens

Trigger: t.SdkClient.AllLookmlModels returns a non-nil error: Looker API unreachable, expired/invalid client credentials (client_id/client_secret), insufficient permissions for the API user, 429 rate limiting, or a malformed base URL in the looker source config.

Common situations: Looker instance behind VPN/firewall unreachable from the toolbox host; API token revoked or rotated; service account lacking view/manage access to LookML; TLS/certificate issues with self-hosted Looker; wrong looker.base_url (http vs https).

Related errors


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