kubernetes/kops · error

invalid openstack cloud storage path: %q

Error message

invalid openstack cloud storage path: %q

What it means

buildOpenstackSwiftPath parses swift:// URLs into a SwiftPath; if url.Parse itself fails it returns "invalid openstack cloud storage path". Purely local validation of the URL string.

Source

Thrown at util/pkg/vfs/context.go:554

	c.mutex.Lock()
	defer c.mutex.Unlock()

	if c.swiftClient != nil {
		return c.swiftClient, nil
	}

	swiftClient, err := NewSwiftClient(ctx)
	if err != nil {
		return nil, err
	}
	c.swiftClient = swiftClient
	return swiftClient, nil
}

func (c *VFSContext) buildOpenstackSwiftPath(p string) (*SwiftPath, error) {
	u, err := url.Parse(p)
	if err != nil {
		return nil, fmt.Errorf("invalid openstack cloud storage path: %q", p)
	}

	if u.Scheme != "swift" {
		return nil, fmt.Errorf("invalid openstack cloud storage path: %q", p)
	}

	bucket := strings.TrimSuffix(u.Host, "/")
	if bucket == "" {
		return nil, fmt.Errorf("invalid swift path: %q", p)
	}

	return NewSwiftPath(c, bucket, u.Path)
}

func (c *VFSContext) buildAzureBlobPath(p string) (*AzureBlobPath, error) {
	if os.Getenv("AZURE_STORAGE_ACCOUNT") != "" {
		return nil, fmt.Errorf("unset AZURE_STORAGE_ACCOUNT; the storage account belongs in the URL:  azureblob://<account>/<container>/<key>")
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Remove or percent-encode invalid characters in the container/key portions of the URL
  2. Print the path with %q to reveal hidden control characters and test it with url.Parse
  3. Re-derive the URL from clean configuration values rather than concatenated free-form input
  4. Trim surrounding whitespace and strip trailing newlines from config file values

Example fix

// before
p := "swift://container/name%2zz"
vfsPath, err := context.BuildVfsPath(p) // parse fails
// after
p := "swift://container/" + url.PathEscape(name)
vfsPath, err := context.BuildVfsPath(p)
Defensive patterns

Strategy: validation

Validate before calling

if _, err := url.Parse(stateStore); err != nil { return fmt.Errorf("swift state store %q is not a valid URL: %v", stateStore, err) }

Type guard

func isParsableSwiftURL(p string) bool { _, err := url.Parse(p); return err == nil }

Try / catch

if _, err := context.BuildVfsPath(p); err != nil { if strings.Contains(err.Error(), "invalid openstack cloud storage path") { /* log the raw path with %q to reveal hidden characters */ } return err }

Prevention

When it happens

Trigger: Calling BuildVfsPath with a swift:// path that url.Parse rejects — invalid percent-encoding (e.g. "swift://container/%zz"), control characters, or other malformed URL syntax.

Common situations: Container or object names pasted with stray characters; secrets or tokens with special characters interpolated into the swift URL; values read from config files with hidden whitespace/control characters.

Related errors


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