{"record":{"id":"8f664d5b0ce3d55c","repo":"kubernetes/kops","slug":"invalid-swift-path-q","errorCode":null,"errorMessage":"invalid swift path: %q","messagePattern":"invalid swift path: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/pkg/vfs/context.go","lineNumber":563,"sourceCode":"\t\treturn nil, err\n\t}\n\tc.swiftClient = swiftClient\n\treturn swiftClient, nil\n}\n\nfunc (c *VFSContext) buildOpenstackSwiftPath(p string) (*SwiftPath, error) {\n\tu, err := url.Parse(p)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid openstack cloud storage path: %q\", p)\n\t}\n\n\tif u.Scheme != \"swift\" {\n\t\treturn nil, fmt.Errorf(\"invalid openstack cloud storage path: %q\", p)\n\t}\n\n\tbucket := strings.TrimSuffix(u.Host, \"/\")\n\tif bucket == \"\" {\n\t\treturn nil, fmt.Errorf(\"invalid swift path: %q\", p)\n\t}\n\n\treturn NewSwiftPath(c, bucket, u.Path)\n}\n\nfunc (c *VFSContext) buildAzureBlobPath(p string) (*AzureBlobPath, error) {\n\tif os.Getenv(\"AZURE_STORAGE_ACCOUNT\") != \"\" {\n\t\treturn nil, fmt.Errorf(\"unset AZURE_STORAGE_ACCOUNT; the storage account belongs in the URL:  azureblob://<account>/<container>/<key>\")\n\t}\n\n\tu, err := url.Parse(p)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse %q: %s\", p, err)\n\t}\n\n\tif u.Scheme != \"azureblob\" {\n\t\treturn nil, fmt.Errorf(\"invalid Azure Blob scheme: %q\", p)\n\t}","sourceCodeStart":545,"sourceCodeEnd":581,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/util/pkg/vfs/context.go#L545-L581","documentation":"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.","triggerScenarios":"Calling BuildVfsPath with \"swift://\", \"swift:///key\", or \"swift://\" plus only slashes — u.Host is empty after trimming \"/\", so the container name is missing.","commonSituations":"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\".","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"],"exampleFix":"// before\nurl := \"swift:///\" + container + \"/backup\"  // container in path\n// after\nurl := \"swift://\" + container + \"/backup\"   // container as host","handlingStrategy":"validation","validationCode":"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>\") }","typeGuard":"func hasSwiftContainer(p string) bool { u, err := url.Parse(p); return err == nil && u.Scheme == \"swift\" && strings.TrimSuffix(u.Host, \"/\") != \"\" }","tryCatchPattern":"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 }","preventionTips":["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"],"tags":["swift","openstack","container","vfs"],"backgroundTag":"invalid-storage-url","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}