kubernetes/kops · error
failed to parse %q: %s
Error message
failed to parse %q: %s
What it means
buildAzureBlobPath parses the azureblob:// URL with url.Parse and wraps any failure as "failed to parse %q: %s", including the underlying parse error text. The path never reached Azure.
Source
Thrown at util/pkg/vfs/context.go:576
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)
}
account := strings.TrimSuffix(u.Host, "/")
if account == "" {
return nil, fmt.Errorf("no storage account specified in %q; expected azureblob://<account>/<container>/<key>", p)
}
rest := strings.TrimPrefix(u.Path, "/")
container, key, _ := strings.Cut(rest, "/")
if container == "" {
return nil, fmt.Errorf("no container specified in %q; expected azureblob://<account>/<container>/<key>", p)
}
return NewAzureBlobPath(c, account, container, key), nilView on GitHub (pinned to 4c8573c808)
Solutions
- Read the wrapped %s detail to see url.Parse's exact complaint
- Percent-encode special characters (notably %, spaces, control chars) in the container/key portions
- Trim whitespace/newlines from values read from files or environment before building the URL
- Test the string with a tiny Go snippet calling url.Parse to reproduce the error locally
Example fix
// before p := "azureblob://acct/container/sas?sig=%zz" context.BuildVfsPath(p) // failed to parse // after p := "azureblob://acct/container/" + url.QueryEscape(sig) context.BuildVfsPath(p)
Defensive patterns
Strategy: validation
Validate before calling
if _, err := url.Parse(stateStore); err != nil { return fmt.Errorf("azureblob state store %q is not a valid URL: %v", stateStore, err) } Type guard
func isParsableAzureBlobURL(p string) bool { _, err := url.Parse(p); return err == nil } Try / catch
if _, err := context.BuildVfsPath(p); err != nil { if strings.Contains(err.Error(), "failed to parse") { /* log err's wrapped url.Parse detail and the %q path */ } return err } Prevention
- Percent-encode % and special characters in keys/SAS tokens
- Strip newlines when reading URLs from config files or env
- Reproduce suspicious URLs with url.Parse in a scratch test
When it happens
Trigger: BuildVfsPath called with an azureblob:// URL that url.Parse rejects: invalid percent-escapes (e.g. "%zz"), embedded control characters or newlines, or other malformed URL syntax in the account/container/key.
Common situations: SAS tokens or keys containing % characters pasted unescaped into the URL; multi-line values from config files; secrets with special characters interpolated into the state-store string.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- parsing etcd backup-store %q: %w
- parsing configStore.base %q: %w
- invalid Azure Blob scheme: %q
- no storage account specified in %q; expected azureblob://<ac
- no container specified in %q; expected azureblob://<account>
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/ee5183c5b3f41ad8.
Report an issue: GitHub.