kubernetes/kops · error
invalid swift path: %q
Error message
invalid swift path: %q
What it means
In buildOpenstackSwiftPath, the URL host is treated as the Swift container; an empty host yields "invalid swift path". Note this branch uses a slightly different message than the scheme/parse branches, so grep for "invalid swift path" specifically.
Source
Thrown at util/pkg/vfs/context.go:563
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>")
}
u, err := url.Parse(p)
if err != nil {
return nil, fmt.Errorf("failed to parse %q: %s", p, err)
}
if u.Scheme != "azureblob" {
return nil, fmt.Errorf("invalid Azure Blob scheme: %q", p)
}View on GitHub (pinned to 4c8573c808)
Solutions
- Put the container in the host position: "swift://<container>/<key>"
- Ensure the container-name config variable is populated and non-empty
- Do not write "swift:///container/key" — the container must be the host, not the first path segment
- Validate the assembled URL string before invoking kops
Example fix
// before url := "swift:///" + container + "/backup" // container in path // after url := "swift://" + container + "/backup" // container as host
Defensive patterns
Strategy: validation
Validate before calling
u, _ := url.Parse(stateStore); if u.Scheme == "swift" && strings.TrimSuffix(u.Host, "/") == "" { return errors.New("swift state store must include a container: swift://<container>/<key>") } Type guard
func hasSwiftContainer(p string) bool { u, err := url.Parse(p); return err == nil && u.Scheme == "swift" && strings.TrimSuffix(u.Host, "/") != "" } Try / catch
if _, err := context.BuildVfsPath(p); err != nil { if strings.Contains(err.Error(), "invalid swift path") { /* the container (URL host) was empty — check the config var */ } return err } Prevention
- Put the container in the host position: swift://<container>/<key>
- Check container-name variables for emptiness before substitution
- Avoid join helpers that emit swift:///path forms
When it happens
Trigger: Calling BuildVfsPath with "swift://", "swift:///key", or "swift://" plus only slashes — u.Host is empty after trimming "/", so the container name is missing.
Common situations: Config template substituting an empty container name; mistaken belief that the first path segment is the container (it must be the host); join helper producing "swift://" + "/path".
Related errors
- invalid openstack cloud storage path: %q
- error building openstack provider client: %v
- error building openstack authenticated client: %v
- error building swift client: %v
- ReadOnlyError
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/8f664d5b0ce3d55c.
Report an issue: GitHub.