{"record":{"id":"f038629dcd81717e","repo":"kubernetes/kops","slug":"invalid-openstack-cloud-storage-path-q","errorCode":null,"errorMessage":"invalid openstack cloud storage path: %q","messagePattern":"invalid openstack cloud storage path: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/pkg/vfs/context.go","lineNumber":554,"sourceCode":"\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\n\tif c.swiftClient != nil {\n\t\treturn c.swiftClient, nil\n\t}\n\n\tswiftClient, err := NewSwiftClient(ctx)\n\tif err != nil {\n\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}","sourceCodeStart":536,"sourceCodeEnd":572,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/util/pkg/vfs/context.go#L536-L572","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove or percent-encode invalid characters in the container/key portions of the URL","Print the path with %q to reveal hidden control characters and test it with url.Parse","Re-derive the URL from clean configuration values rather than concatenated free-form input","Trim surrounding whitespace and strip trailing newlines from config file values"],"exampleFix":"// before\np := \"swift://container/name%2zz\"\nvfsPath, err := context.BuildVfsPath(p) // parse fails\n// after\np := \"swift://container/\" + url.PathEscape(name)\nvfsPath, err := context.BuildVfsPath(p)","handlingStrategy":"validation","validationCode":"if _, err := url.Parse(stateStore); err != nil { return fmt.Errorf(\"swift state store %q is not a valid URL: %v\", stateStore, err) }","typeGuard":"func isParsableSwiftURL(p string) bool { _, err := url.Parse(p); return err == nil }","tryCatchPattern":"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 }","preventionTips":["Percent-encode object names containing special characters","Strip control characters when reading swift URLs from files","Validate all state-store URLs once at config-load time"],"tags":["swift","openstack","url-parsing","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"}