kubernetes/kops · error

cannot infer cloud provider from path: %q

Error message

cannot infer cloud provider from path: %q

What it means

GuessCloudForPath infers the cloud provider from a VFS/URL path (e.g. s3://, gs://, ssh paths). When the path's scheme does not map to any supported provider it returns this error. It means kops cannot determine which cloud implementation to use for the given location.

Source

Thrown at pkg/clouds/supported.go:74

	case strings.HasPrefix(path, "hos://"):
		return kops.CloudProviderHetzner, nil
	case strings.HasPrefix(path, "gs://"):
		return kops.CloudProviderGCE, nil
	case strings.HasPrefix(path, "linode://"):
		return kops.CloudProviderLinode, nil
	case strings.HasPrefix(path, "scw://"):
		return kops.CloudProviderScaleway, nil
	case strings.HasPrefix(path, "swift://"):
		return kops.CloudProviderOpenstack, nil
	case strings.HasPrefix(path, "s3://"):
		if os.Getenv("HCLOUD_TOKEN") != "" {
			return kops.CloudProviderHetzner, nil
		} else if os.Getenv("LINODE_TOKEN") != "" {
			return kops.CloudProviderLinode, nil
		}
		return kops.CloudProviderAWS, nil
	default:
		return "", fmt.Errorf("cannot infer cloud provider from path: %q", path)
	}
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Use a supported state-store scheme (s3://, gs://, azure://, do://, hetzner://, openstack:// etc.) or a path whose env tokens identify the cloud.
  2. Export the cloud-specific env var (e.g. AWS_PROFILE/credentials, OS_* for OpenStack) so the inference branch matches.
  3. Pass the cloud provider explicitly to the command instead of relying on path inference.

Example fix

// before
cloud, err := GuessCloudForPath("https://my-bucket/state")
// after
cloud, err := GuessCloudForPath("s3://my-bucket/state")
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(path)
if err != nil || u.Scheme == "" {
  return fmt.Errorf("state store path %q must use a supported scheme (s3://, gs://, ...)", path)
}

Try / catch

cloud, err := GuessCloudForPath(path)
if err != nil {
  return fmt.Errorf("could not infer cloud; pass --cloud or use a recognized state-store URL: %w", err)
}

Prevention

When it happens

Trigger: Calling GuessCloudForPath (directly or via NewCluster) with a path whose scheme is not recognized — e.g. file:///state, an HTTPS URL, a typo'd scheme (s4://), or an empty path.

Common situations: Creating/upgrading a cluster with a state store on an unsupported backend; typos in the -state flag; using OSS/Swift endpoints without the matching env config that the recognized branches check (e.g. OS_/AWS_ env vars).

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/5b33c0cd5df58542. Report an issue: GitHub.